def _get_save_args()

in modular_sdk/models/pynamodb_extension/base_safe_update_model.py [0:0]


    def _get_save_args(self, null_check: bool = True, condition=None,
                       add_version_condition: bool = True):
        """
        Gets the proper *args, **kwargs for saving and retrieving this object
        :param null_check: If True, then attributes are checked for null
        :param condition: If set, a condition
        """
        attribute_values = self.serialize(null_check)
        # ---- our code below ----
        dct = DynamoDBJsonSerializer.deserialize_model(attribute_values)
        self._update_with_additional_data(
            document=dct,
            additional_data=getattr(self, self._additional_data_attr_name, {})
        )
        attribute_values = DynamoDBJsonSerializer.serialize_model(dct)
        # ---- our code above ----
        hash_key_attribute = self._hash_key_attribute()
        hash_key = attribute_values.pop(hash_key_attribute.attr_name, {}).get(
            hash_key_attribute.attr_type)
        range_key = None
        range_key_attribute = self._range_key_attribute()
        if range_key_attribute:
            range_key = attribute_values.pop(range_key_attribute.attr_name,
                                             {}).get(
                range_key_attribute.attr_type)
        args = (hash_key,)
        kwargs = {}
        if range_key is not None:
            kwargs['range_key'] = range_key
        version_condition = self._handle_version_attribute(
            attributes=attribute_values)
        if add_version_condition and version_condition is not None:
            condition &= version_condition
        kwargs['attributes'] = attribute_values
        kwargs['condition'] = condition
        return args, kwargs