On Jun 8, 2008, at 5:02 AM, [EMAIL PROTECTED] wrote:
>
> hi
> i'm trying to make a metainfo extractor off some relation attribute.
> by metainfo i mean the klas and attr-name of this and of the other
> side of the relation-attribute, or of the parent or child of the
> relation regardless the start point.
>
> e.g. possible usage and testing invariants is like:
> a = about_relation( someklas.someproperty)
> print a.name, a.klas, 'is_parent:', a.is_parent
> assert a.thisside == a
> b = a.otherside
> print b.name, b.klas, 'is_parent:', b.is_parent
> assert a.otherside.otherside == a
> if a.is_parent:
> assert a.child is a.otherside
> assert a.parent is a.thisside
> else:
> assert a.parent is a.otherside
> assert a.child is a.thisside
> e.g. if Parent.kids / Kid.parent are 1:many:
> print about_relation( Parent.kids).otherside.name -> 'mama'
> print about_relation( Parent.kids).otherside.klas -> 'Kid'
> print about_relation( Parent.kids).child.klas -> 'Kid'
> print about_relation( Kid.parent).child.klas -> 'Kid'
> print about_relation( Kid.parent).parent.klas -> 'Parent'
> print about_relation( Kid.parent).otherside.name -> 'kids'
def about_relation(descriptor):
prop = descriptor.property
return {
'child':{'name': prop.key, 'klas': prop.mapper.class_}
'parent':{'klas':prop.parent.class_}
}
I don't understand what "is_parent" means (nor 'thissside' and
'otherside'). every relation has a "parent" and "child".
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---