Am 16.02.2011 11:58 schrieb Abdul Gaffar:
I need urgent help on SQLAlchemy relations. I have three classes User,
Group, Project and association user_group_table.

As Michael already said, you should ask pure SQLAlchemy questions on their mailinglist.

Also, you didn't specify what your actual problem is. Do you get an error message? If yes, which?

Or is it more a conceptual problem? Then you should better explain what you really want, what the relationships between users, groups and projects you want to implement. It's a bit strange that you use the user_group association table also for projects. Maybe that's what you want, but then you should change the name, but probably you want something different. Also the project attribute of the Project class looks strange, it should be called groups.

Some more notes:

user = DBSession.query(User).filter(User.user_name == kw['PM']).one()

This can be formulated a bit simpler:

user = DBSession.query(User).filter_by(user_name=kw['PM']).one()

And if you set DeclarativeBase.query = DBSession.query_property()
in your model package init file, then you can write

user = User.query.filtery_by(user_name=kw['PM']).one()

And

project = DBSession.query(Project).\
    filter(Project.project_id == kw['project_id']).one()

could be simpler:

project = Project.query.get(kw['project_id'])

-- Christoph

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