Can't you define the ContentCollection mapper without any reference to
Content, and then when you define the Content mapper, you can set up two
relations to ContentCollection with appropriate backrefs?
If that doesn't work, you can add properties to a mapper after it has
been defined, so you can create the basic mappers without the relations,
and then say something like:
class_mapper(Content).add_property('collection_children',
relation(ContentCollection,
backref='content'))
Simon
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf Of Matt
Sent: 23 June 2007 19:51
To: sqlalchemy
Subject: [sqlalchemy] Re: advanced mapping help
Thanks I think I had tried something like this before... Anyway, now
I'm defining the relation from Content to ContentCollection and
separately from ContentCollection back to Content, but I'm running
into the chicken and the egg problem... The mapper expects a class,
but I can't define Content before ContentCollection and
ContentCollection before Content...
thx
m
On Jun 22, 11:32 pm, [EMAIL PROTECTED] wrote:
> u may need an explicit intermediate association object, see the docs
> about "many to many" relations.
> Instead of directly getting the children, u'll get the associations
> via which u can get the children, or whatever attributes of the link.
> Then if u want a direct children-list, u can make some python property
> to do that i.e. return [x.child for x in me.children_links].
>
> > Hi, I have a relation I'm mapping through an intermediate table and
> > it seems to work fine, it looks something like:
>
> > Content -> ContentCollection -> Content
>
> > 'collection_children':relation(Content,
> > secondary = content_collection,
> > primaryjoin = content.c.id ==
> > content_collection.c.collection_id,
> > secondaryjoin =
> > content_collection.c.content_id == content.c.id,
> > order_by =
> > content_collection.c.priority,
> > ),
>
> > The trouble is, I want to be able to set a couple fields on the
> > ContentCollection table, but I don't actually have a property for
> > those fields on the Content object anywhere since I'm mapping
> > through that table... Any ideas on how I should handle this?
>
> > thx
>
> > Matt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---