Hi. I recently switched a sqlalchemy project from using manual mapping
of classes to ext.declarative.

This is in a turbogears project and I am using their metadata and
mapper. Before I had:

from turbogears.database import metadata, mapper
users_table = sqlalchemy.Table('users', metadata, ... )
class User(object): pass
mapper(User, users_table)

And now I have:

from turbogears.database import metadata, mapper
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base(metadata=metadata)
class User(Base):
    __tablename__ = 'users'
    __mapper__ = mapper
    ...

I had thought that these approaches were different syntaxes for the
same thing and would produce equivalent classes. However, this isn't
the case. In particular, I used to have a User.query property (which I
believe is a side effect of a class being tied to a scoped session?)
and now it is gone. I have to use session.query(User) instead.

Any idea how I can get User.query back and have my classes
automatically associated with my session again? I really like
declarative and it would be disappointing to have to go back to manual
mapping of class just for that.

Thanks for any suggestions.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to