Here's a way to do it without any plain SA. In the tests, just delete
the two .refresh() lines. This should be fairly simple to add to Elixir.
What would be the appropriate syntax to add?
Perhaps:
has_many('twos', of_kind='ThingTwo', inverse='ones',
proxy_class='Cat' proxy_through='two',
proxy_name='cats', order_by=Cats.c.sorter)
Or maybe less complex, but requiring a matching has_many('cats'...):
has_association('twos', relation='cats', proxy_via='two')
... something like that?
Anyway, here's model code that passes tests already:
---------------------------------
from sqlalchemy import *
from sqlalchemy.ext.associationproxy import AssociationProxy
from turbogears.database import metadata, session
from elixir import Unicode, DateTime, String, Integer, Boolean,
Float, PickleType
from elixir import Date, Time, Entity, has_field, using_options, has_one
from elixir import has_many, belongs_to, has_and_belongs_to_many
class ThingOne(Entity):
has_field('name', Unicode)
has_many('cats', of_kind='Cat', inverse='one', order_by='sorter')
twos = AssociationProxy('cats', 'two')
using_options(tablename='thing_one')
class ThingTwo(Entity):
has_field('name', Unicode)
has_many('cats', of_kind='Cat', inverse='two', order_by='sorter')
ones = AssociationProxy('cats', 'one')
using_options(tablename='thing_two')
class Cat(Entity):
belongs_to('one', of_kind='ThingOne')
belongs_to('two', of_kind='ThingTwo')
has_field('sorter', Integer)
using_options(tablename='cats_in_hats')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---