def get(self, instance, aslist=False, **kwargs): """Return the value of the version as a list of integers. Example: [1,10] Except (and this is important!) if there is no value or our value is 'latest', then return an empty list: [] The OOBTree, probably through Python cmp(), sorts all tuples after all lists. So if we make the versions as lists and the "no version" as a tuple, we will get no-version entries as "high" values instead of low. Only tuples, apparently, order above tuples. This is not guaranteed to be stable, and we absolutely must have a test for at least this! TODO! """ val = StringField.get(self, instance, **kwargs) if not val or val == 'latest': # 'latest' and '' sort to end... return tuple() # ...tricksy. See docstring. else: try: return [int(x) for x in val.split('.')] except ValueError: # probably a mistake. TODO: should we just let this float? return val # not doing so, we could get bad comparisons...
def getRaw(self, instance, aslist=False, **kwargs): """Return the value of the version as a string. Example: '1.10' """ return StringField.get(self, instance, **kwargs)