j***@gmail.com
2018-09-01 10:57:10 UTC
Hi,
According to the documentation here
<https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/>, âPyramid
<https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/glossary.html#term-pyramid>
requests [to] join the active transaction
<https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/glossary.html#term-transaction>
as provided by the Python transaction
<https://pypi.org/project/transaction/> packageâ. Looking at the
transactions code, the default transaction manager used is a
ThreadTransactionManager
<https://github.com/zopefoundation/transaction/blob/501a2934a1031f4def92701a44ebca8a317dd8a6/transaction/_manager.py#L212>,
i.e. one transaction per Python execution thread.
Now I did follow the Pyramid-SQLAlchemy-Cookiecutter
<https://github.com/Pylons/pyramid-cookiecutter-alchemy/> recipe where DB
sessions join the requestâs transaction. Considering that a single incoming
request is handled in Pyramid by a single thread (correct?) is it safe to
say that the following is true?
import transaction
@view_config(âŠ)
def some_view(request):
# Request's transaction manager is the thread's transaction manager.
request.tm == transaction.manager
# Request's and thread's and tm's transaction is the same object.
request.tm.get() == transaction.get() # == transaction.manager.get()
Thanks!
Jens
According to the documentation here
<https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/>, âPyramid
<https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/glossary.html#term-pyramid>
requests [to] join the active transaction
<https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/glossary.html#term-transaction>
as provided by the Python transaction
<https://pypi.org/project/transaction/> packageâ. Looking at the
transactions code, the default transaction manager used is a
ThreadTransactionManager
<https://github.com/zopefoundation/transaction/blob/501a2934a1031f4def92701a44ebca8a317dd8a6/transaction/_manager.py#L212>,
i.e. one transaction per Python execution thread.
Now I did follow the Pyramid-SQLAlchemy-Cookiecutter
<https://github.com/Pylons/pyramid-cookiecutter-alchemy/> recipe where DB
sessions join the requestâs transaction. Considering that a single incoming
request is handled in Pyramid by a single thread (correct?) is it safe to
say that the following is true?
import transaction
@view_config(âŠ)
def some_view(request):
# Request's transaction manager is the thread's transaction manager.
request.tm == transaction.manager
# Request's and thread's and tm's transaction is the same object.
request.tm.get() == transaction.get() # == transaction.manager.get()
Thanks!
Jens
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+***@googlegroups.com.
To post to this group, send email to pylons-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/79da9d5a-91e9-483e-b96f-b5e54cc3f1a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+***@googlegroups.com.
To post to this group, send email to pylons-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/79da9d5a-91e9-483e-b96f-b5e54cc3f1a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.