> map_column is shorthand for this: > > table = Table('sometable', metadata, > ... > Column('somecolumn', ...) > ) > > mapper(Class, table, properties= { > '_somecolumn':table.c.somecolumn, > 'somecolumn':synonym('_somecolumn') > > }) > > so the argument does not apply to your "parent" relation since its not > a column-based attribute, its a relation(). Also the small snip you > sent didn't seem to have any need for a synonym on parent, unless > there are other properties in your code that weren't part of what you > sent.
So, should I delete the column_prefix from the code I sent, and change the code in the calls to synonym()? (following the mapper code) mapper(Resource, resources, polymorphic_on=resources.c.type, polymorphic_identity="empty", column_prefix='_', properties={ 'id': resources.c.id, 'url': synonym('_url', map_column=True), 'children': relation(Resource, backref=backref("_parent", remote_side=[resources.c.id])), 'parent': synonym('_parent', map_column=True), 'name': synonym('_name', map_column=True), 'type': resources.c.type, # NOTE: Remember to add here other columns that don't need # a custom property accessor, like the id. Otherwise, they # be available as _column_name, not column_name. }, save_on_init=False, ) I do have properties for url (this is the example I sent), parent and name. When I deleted map_column from 'parent': synonym('_parent', map_column=True) and imported the module everything was all right. But when I run my tests (basically just creating a Resource() object and setting properties to see if the code in them work properly), it raises and exception: File "[...]/model/resources.py", line 118, in _set_url self.parent.save() AttributeError: 'Resource' object has no attribute 'parent' Which only happens when I try to access Resource().parent.*; when I "print repr()" Resource().parent there is no problem... Apparently this problem is only with parent. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---