On 5/22/07, AZMel <[EMAIL PROTECTED]> wrote:
>
> Ive been having trouble doing a simple Left Join with SQLAlchemy and
> TG.  I tried using pure SQLAlchemy but when that failed I switch to
> trying Elixir.  Always get the same error.  I've seen multiple
> references to use the method I am trying but I cannot get it to work.
> Here's the datails --
>
> model.py:
>
> class Division(Entity):
>       has_field('Division_id', Integer, primary_key=True)
>       has_field('Name', String(3), unique=True)
>       using_options(tablename='division')
>
> class SubDivision(Entity):
>       has_field('Subdivision_id', Integer, primary_key=True)
>       has_field('Name', String(45), unique=True)
>       has_field('DisplayOrder', Integer)
>       belongs_to('division', of_kind='Division',
> colname='Division_id', use_alter=True)
>       using_options(tablename='subdivision')
>
>       @classmethod
>       def by_Name(klass, Name):
>         return klass.get_by(subdivision_table.c.Name==Name)
>
> ---and pass it to the list template---
>
> controller:
>     def list(self, **kw):
>         records =
> SubDivision.Join(Division).select(order_by=Division.c.division_id).execute()
>
> ---but I get the error---
>
>     records =
> SubDivision.Join(Division).select(order_by=Division.c.division_id).execute()
>     AttributeError: type object 'SubDivision' has no attribute 'Join'
>
> What am I doing wrong?  I've looked up all the examples I could find
> the past 2 days but I'm coming up empty.

Try:
SubDivision.join('division')...

Notice the lowercase "j". 'division' is the name of the relation, not
the name of the class.

See 
http://www.sqlalchemy.org/docs/sqlalchemy_orm_query.html#docstrings_sqlalchemy.orm.query_Query
for details.


-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to