I have two tables, merchants and deals. The merchants table is
represented by Merchant and deals table by Deal.

Each merchant can have 0, 1, or many deals. Some of those deals will
be available, while others will be expired or coming soon or deleted.
Each deal belongs to exactly one merchant.

I'd like to setup Merchant to have attributes "deals",
"available_deals", "expired_deals", "upcoming_deals", and
"deleted_deals".  These would return, obviously, deals from those
groups.

The twist is that I've spread out my tables and ORM classes across
several files. I've tried to keep it so that I don't have circular
dependencies. That means I've defined Merchant first, and then Deal
later, in separate files

It looks like this:

in model/merchant.py:
  merchants = Table(...)
  class Merchant(object): ...
  mapper(Merchant, merchants)

in model/deal.py:
  deals = Table(...)
  class Deal(object): ...
  mapper(Deal, deals, properties=dict(
      merchant=relationship(Merchant, backref='deals'),
  ))

What can I sprinkle in model/deal.py's mapper call to add backrefs to
'available_deals', 'deleted_deals', etc...?

Or am I going about this all wrong?

Thanks in advance. BTW, SQLAlchemy is, by far, the most superior ORM
in the history of the world, bar none, IMHO.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.

Reply via email to