sorry to ride your thread but just to add related question: how can a reference be seen as its key/id and never the referred instance? turn off some postprocessing in properties/instrumentedAttr, or not map it at all?
On Friday 27 June 2008 17:12:21 Paul-Michael Agapow wrote: > I've got a scenario here that seems as if it would be simple to > solve, but it baffling me so far. Pointers in the right direction > would be appreciated. > > I have a table of Foo objects, and FooCollection objects. In a > classic many-to-many, a collection may contain a number of Foos, > and any given Foo may belong to multiple collections. So far so > simple. So we create an intermediate table and map accordingly: > > class Foo (object): > ... > > class FooCollection (object): > ... > > table_foocollections = Table ('foocollections', mymetadata, > ...) > > table_foo = Table ('foo', mymetadata, ...) > > table_foocollections_foo = Table ('foocollection_foo', > mymetadata, > Column ('collection_id', > None, > ForeignKey ('foocollections.id'), > primary_key=True > ), > Column ('foo_id', > None, > ForeignKey ('foo.id'), > primary_key=True, > ), > ) > > mapper (FooCollection, table_foocollections, > properties={ > 'members': relation (FooCollection, > secondary=table_foocollections_foo, > ), > }, > ) > > So when I retrieve or update a FooCollection, "members" has all the > contained Foos. > > But, I have a situation where I don't want FooCollection to > actually contain the actual Foos, just a list of their keys. That > is, Foos and FooCollections have to be handled separately. > Obviously it will involve more paperwork, but how can I make the > "members" attribute just contain the keys? Is a mapper extension > required, or is there a simpler way? > > p --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---