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()--
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-discus...@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.
settings = config.get_settings()settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'You are talking about these two lines of code in the cookiecutter’s model/__init__.py, correct?
Using that manager hook I can then derive from an explicit manager and extend with custom functionality—and that would be the recommended way of doing so? That may help me solve a question I just asked at the transaction Github repo (see issue #62 there).
Would it make sense to use a custom request factory to implement such a thread local approach? Are there other recommendations, considering the warnings in pyramid.threadlocal?
So I thought it would be useful if much/all of a request’s execution context would be available through the current thread local memory. However, reading Why You Shouldn’t Abuse Thread Local (see the pyramid.threadlocal module) recommends against such an approach. Are there more recent and different recommendations?
--
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-discus...@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/5b86bb49-8fb5-4ebe-ad2b-c3a4da52bad3%40googlegroups.com.
Added yet another one or two parameters (sigh) to functions, but it keeps things functional and without outside (global, thread-local) state.
Thank you Mike for the information, that all makes sense. I ended up with the same approach that SQLA takes: a “Session” object owned by a DataManager, joined to the Request’s TransactionManager. And then just pass a `dbsession` and `fnsession` and `jobsession` around to functions as needed.Added yet another one or two parameters (sigh) to functions, but it keeps things functional and without outside (global, thread-local) state.
--
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-discus...@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/148c7bec-2d75-4525-9aa4-3902a4a2f2cb%40googlegroups.com.