Example #1
0
def what_QVersionSerializerField_used_to_do(serialized_value):
    if isinstance(serialized_value, Version):
        return serialized_value.fully_specified()
    else:
        # TODO: JUST DOUBLE-CHECKING THINGS HERE, I'M NOT ENTIRELY CLEAR ON THE ORDER THAT THINGS GET SERIALIZED...
        # (it seems that it varies based on whether this is a new or existing model)
        assert isinstance(serialized_value, int)
        return Version.int_to_string(serialized_value)
Example #2
0
 def to_internal_value(self, data):
     # given a serialized representation of a version, return a Pythonic representation
     # (this should basically do the same thing as "QVersionField.to_python")
     if isinstance(data, Version):
         return data
     if isinstance(data, basestring):
         return Version(data)
     if data is None:
         return None
     return Version(Version.int_to_string(data))
Example #3
0
    def to_python(self, value):
        """
        db to code; int to Version
        """
        if isinstance(value, Version):
            return value

        if isinstance(value, str):
            return Version(value)

        if value is None:
            return None

        return Version(Version.int_to_string(value))
Example #4
0
    def to_python(self, value):
        """
        db to code; int to Version
        """
        if isinstance(value, Version):
            return value

        if isinstance(value, basestring):
            return Version(value)

        if value is None:
            return None

        return Version(Version.int_to_string(value))