Admin controller issue with ZTE

12 views
Skip to first unread message

D R Dinesh Kumar

unread,
May 11, 2017, 1:30:45 PM5/11/17
to TurboGears
Hi All,

I am using the following statement to create DB session

maker = sessionmaker(autoflush=True, autocommit=False,
                      extension=ZopeTransactionExtension())
DBSession = scoped_session(maker)

and in my app, I have created model view admin controllers for user,group etc.
when I try to edit users, I am hitting the following issue.

File "/remote/vtghome9/vgtools2/VPython2.7.13/lib/python2.7/site-packages/transaction/_transaction.py", line 423, in _commitResources
rm.tpc_vote(self)
File "/remote/vtghome9/vgtools2/VPython2.7.13/lib/python2.7/site-packages/zope/sqlalchemy/datamanager.py", line 109, in tpc_vote
self.tx.commit()
File "/remote/vtghome9/vgtools2/VPython2.7.13/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 459, in commit
self._assert_active(prepared_ok=True)
File "/remote/vtghome9/vgtools2/VPython2.7.13/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 285, in _assert_active
raise sa_exc.ResourceClosedError(closed_msg)
ResourceClosedError: This transaction is closed

Any help is greatly appreciated.!!

Possible issue:: Since ZTE is used, calling .commit() explicitly is not required. 

is there a way to handle this to create different session (without ZTE) for AdminController to use?

With Regards,
Dinesh.

Alessandro Molina

unread,
May 12, 2017, 3:28:29 AM5/12/17
to TurboGears
There should be something else in your code causing the transaction to be completed before the transaction manager tries to commit it.
Do your models have any even listener or something else that might be trying to commit changes before the end of the request? In TG2 unless the transaction manager is disabled you should never commit or rollback the transaction yourself, you let it go or you doom it.



--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+unsubscribe@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

D R Dinesh Kumar

unread,
May 19, 2017, 4:59:01 AM5/19/17
to TurboGears
Hi Alessandro,

I have set use_transaction_manager=1 so I let tg handle all transactions.
I have tried using different DBSession for AdminController which resolved this issue.
Later on, I have reverted the changes and DB restart happened (due to some other reason), surprisingly I didnt see this issue after that. Will test this again after some time!!
Thanks.

With Regards,
Dinesh.
Reply all
Reply to author
Forward
0 new messages