Exactly. One is getting instantiated by myself (using sqlalchemy, as I
need to do some complex mappings, and activemapper is insufficient),
and the other is getting instiantiated by the generated code for
identity management. Giving my code below.

I feel if turbogears would also support generating SQLAlchemy code
apart from ActiveMapper code, these complexities could be handled
easily. Do you too think same way, can I post a ticket for it?

Thanks
Sanjay

Code
--------------------------------------------------------------------
I have a models package:

#__init__.py
from user import User
from contact import Contact

# user.py
import turbogears
from sqlalchemy import *
from turbogears.database import metadata
turbogears.database.bind_meta_data()
user_tbl = Table('tg_user', metadata, autoload=True)
class User(object):
     pass

#contact.py
from sqlalchemy import *
from sqlalchemy.ext.assignmapper import assign_mapper
from turbogears.database import metadata, session
from user import *

contact_tbl = Table('contact', metadata, autoload=True)
class Contact(object):
     pass
assign_mapper(session.context, User, user_tbl, properties = {
    'contacts' :
    relation(Contact,
primaryjoin=user_tbl.c.user_id==contact_tbl.c.user_id,
association=User)
    })

assign_mapper(session.context, Contact, contact_tbl, properties = {
    'user' :
    relation(User,
primaryjoin=user_tbl.c.user_id==contact_tbl.c.contact_id)
    })

#controllers.py
.
.
from models import *
.
.


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

Reply via email to