Hey Laurence,
Laurence Rowe wrote:
[snip]
We'll have to stick with scoped sesssions because of threading, but the
engine as local utility pattern should still work.
#myapplication/__init__.py
Session = scoped_session(sessionmaker(bind=LookupEngine('my-engine')...))
engine = EngineUtility(url='sqlite:///')
provideUtility(engine, IConnectable, 'my-engine') # but normally a local
utility registration
#myapplication/foo.py
from myapplication import Session
session = Session()
Here one still needs to instantiate the session each time you use it.
Couldn't you simply do:
#myapplication/__init__.py
... [what you had]
session = Session()
# myapplication/foo.py
from myapplication import session
or wouldn't that be possible?
One (perhaps the only) advantage I can see with looking up the scoped
session as a utility is that it gives the integrator control over
whether to use one or two phase commit, as this is set in the session
configuration. Normally one would prefer one-phase commit as it is
faster, but if an integrator arranged for two applications to be
modified in a single transaction she would want to configure two-phase
commit.
How common would it be that the integrator would do this without the
code itself needing to be changed for other reasons then too? A WSGI
setup, perhaps?
I imagine we could arrange something where we allow both. Provide the
engine as local utility scenario, but let people register sessions as
local utilities should they want to.
Regards,
Martijn
_______________________________________________
Zope-Dev maillist - [email protected]
http://mail.zope.org/mailman/listinfo/zope-dev
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )