On Monday 18 May 2009 12:32:31 Sanjay wrote:
> > > @expose()
> > > def insert_a_record(self):
> > >     DBSession.connection().execute(foo_table.insert({'user_id':2,
> > > 'org_id': 2}))
> > >     return "Successfu!"
> >
> > The problem here is that you're actually not using the db session here,
> > but doing things past the db session.
> >
> > The right and much simpler way is to add your data records to the
> > session using DBSession.add().
> >
> > In this case, your table looks like an association table between a User
> > and Org class. Usually the User class then has an orgs attribute which
> > is a list, and vice versa (see how it is implemented in the auth model).
> > You would then simply append the org to the user.orgs list.
>
> I am using dynamic_loader, .i.e. user.orgs is a query object and not a
> list:
>
> orgs = dynamic_loader('Org', secondary=foo_table)
>
> Curious to get some suggestions in this case.

What happens if you leave out the connection()-call? Directly using execute on 
the session should be supported (and thus use the session)

Diez

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