> > @expose()
> > def insert_a_record(self):
> > DBSession.connection().execute(foo_table.insert({'user_id':2,
> > 'org_id': 2}))
> > return "Successfu!"
>
> > This controller returns successfully, but in the database the record
> > is not inserted. Unable to understand why. Need help.
> What's "DBSession" ?
>
> If it isn't the session useg by TG than you must explicit the commit()
It is the DBSession used by TG. That is, in the model/__init__.py, I
have the lines:
maker = sessionmaker(autoflush=True, autocommit=False,
extension=ZopeTransactionExtension())
DBSession = scoped_session(maker)
and then, I have imported this in the controller:
from myproject.model import DBSession
In fact, I tried DBSession.commit() but got this error:
AssertionError: Transaction must be committed using the transaction
manager
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---