Hi all,
There anyway to keep the ordering of properties defined on a mapper?
The reason I ask is that I'm building a tabbed interface consiting of
a parent form and multiple related child forms and I'd like the tabs
to be in the same order that I've defined the properies on the parent
mapper:
In [1]: from mymod import MyModel
In [2]: from sqlalchemy.orm import class_mapper
In [3]: map = class_mapper(MyModel)
In [4]: from sqlalchemy.orm.properties import RelationProperty
In [5]: props = [p for p in map.iterate_properties if isinstance(p,
RelationProperty)]
In [7]: [(p.key, p.collection_class) for p in props]
Out[7]:
[('prop_one', None),
('prop_three', None),
('prop_two', None)]
where my properties look like:
properties=SortedDict({
'prop_one' : relation(RelatedOne,
cascade="all,delete"),
'prop_two' : relation(RelatedTwo,
cascade="all,delete"),
'prop_three' : relation(RelatedThree,
cascade="all,delete")})
Note above that I've tried it with django's SortedDict, I also did it
with a vanilla dict and the odering was still the same.
Actually I've just read through the source and seen that mapper._props
is an instance of util.OrderedDict, so I guess this is more of a
question of how to control the order that properties are inserted into
here.
TIA,
Ben
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.