I've traced it further, and it's an odd problem. This syntax works fine:
memberProfile = self.session.query(MemberProfile).filter (MemberProfile.memberID.in_(memberid)).order_by (MemberProfile.memberID) memberProfile = memberProfile.filter(MemberProfile.city == 'Jamaica') memberProfile = memberProfile.filter(MemberProfile.zip == "11432") memberProfile = memberProfile.order_by (MemberProfile.memberID).all() But this causes the error: for field,value in fields.iteritems(): internal_field = getattr(MemberProfile,field) memberProfile = memberProfile.filter(internal_field == value) memberProfile = memberProfile.order_by (MemberProfile.memberID).all() A trace reveals what I expect: (Pdb) > /var/www/ReST/models/MemberInfo.py(65)GET() -> if fields: (Pdb) > /var/www/ReST/models/MemberInfo.py(66)GET() -> memberProfile = self.session.query(MemberProfile).filter (MemberProfile.memberID.in_(memberid)) (Pdb) > /var/www/ReST/models/MemberInfo.py(67)GET() -> for field,value in fields.iteritems(): (Pdb) > /var/www/ReST/models/MemberInfo.py(69)GET() -> internal_field = getattr(MemberProfile,field) (Pdb) p field 'city' (Pdb) p value 'Jamaica' (Pdb) n > /var/www/ReST/models/MemberInfo.py(70)GET() -> memberProfile = memberProfile.filter(internal_field == value) (Pdb) p MemberProfile.city <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0xb7796d8c> (Pdb) p internal_field <sqlalchemy.orm.attributes.InstrumentedAttribute object at 0xb7796d8c> A "getattr" returns the same address as the MemberProfile.city. So this should work, and worked perfectly when I inherited one class from the other. Here is the error: File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.5.0rc4-py2.4.egg/ sqlalchemy/orm/sync.py", line 28, in clear raise AssertionError("Dependency rule tried to blank-out primary key column '%s' on instance '%s'" % (r, mapperutil.state_str(dest))) AssertionError: Dependency rule tried to blank-out primary key column 'member_profiles.memberID' on instance '<MemberProfile at 0x-488574b4>' Very strange. The object returned by getattr seems the same. Am I missing something? Thanks once again, Gloria --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---