We have the following initialization:
In <project>.model.meta.py:
Session = scoped_session(sessionmaker(expire_on_commit=True))
In <project>.model.__init__.py:
from <project>.model import meta
def init_model(engine):
meta.Session.configure(bind=engine)
And in <project>.lib.base.py:
class BaseController(WSGIController):
def __call__(self, environ, start_response):
try:
return WSGIController.__call__(self, environ, start_response)
finally:
meta.Session.close()
meta.Session.remove()
In the previously mentioned discussion, Daniel Holth, suggests something
slightly different which I have interpreted to mean the following for
base.py:
**
* def __call__(self, environ, start_response):*
* try:*
* return WSGIController.__call__(self, environ, start_response)*
* meta.Session.commit()*
* except:*
* Session.rollback()*
* raise*
* finally:*
* meta.Session.remove()*
However, if we are doing explicit commits in our controller actions then I
assume it accomplishes the same thing, although I do like the addition of
the except block with the rollback. I don't know if our call to close() is
necessary or not - for now we have it for superstitious reasons.
On 22 November 2010 16:12, cd34 <[email protected]> wrote:
> remember that the docs were wrong in a few places and Mike Bayer/Ben
> Bangert/Mike Orr(?) fixed the docs/examples/templates a while back.
>
> You're running the same stack I run on about 70% of our Pylons apps
> (and currently 100% of our Pyramid apps) with -p 8 through -p 16 and
> I've never seen it on startup, and since modifying Pyramid, haven't
> seen it there with the settings as mentioned above. I only saw the
> error when a thread was idle for more than the cli timeout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<pylons-discuss%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en.