> so far so good, but i was wondering, the result
> phonenumber list is unordered. is there a way to specifiy an order
> of such list? i've seen
> a _defaultOrder in the manual but seems related to Person.q or
> Person.select. i've tried to specify a _defaultOrder in PhoneNumber
> with:
>
> class PhoneNumber(SQLObject):
> """Phone number"""
>
> _defaultOrder = "PhoneType"
>
Yes, I highly support this modification. I've suggested it a time or
two, but we've been holding back to determine whether it's worthwhile
to use database-side ORDER BY (which requires a somewhat noticeable
change to the join SQL). For a while now, we've been using
python-side sorts without noticeable issues.
at the end of each performJoin function, replace:
return [cls(id) for (id,) in ids]
with:
objs = [cls(id) for (id,) in ids]
if cls._defaultOrder:
order = cls._defaultOrder
objs.sort(lambda x,y: cmp(getattr(x, order), getattr(y, order)))
return objs
Ugh, but functional.
|