On Mon, Nov 22, 2010 at 11:01 AM, Daniel Holth <[email protected]> wrote:
> This pitfall can be avoided by using SQLAlchemy properly.
>
> # Session is configured, but never reassigned:
> Session = orm.sessionmaker()
>
> def initialize(engine):
>    Session.configure(bind=engine)

This is the way to go, but isn't Josh doing it already?

The Session class takes care of creating session objects as necessary
and setting their bind attribute. There may be a problem of an
existing session object when Session.configure is called, but you
should be calling initialize() at the very beginning of the
application in environment.py, before the middleware stack has been
set up.

The Pylons SQLAlchemy template used to set Session to None initially,
but some users complained that they couldn't import Session directly
in that case, they had to import meta.session. The Session.configure
solution is recommended by SQLAlchemy's author Mike Bayer, so that's
why Pylons is using it now.

-- 
Mike Orr <[email protected]>

-- 
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.

Reply via email to