On Sep 20, 8:12 pm, Damjan <[email protected]> wrote:
> > By the way can somebody explain me this trick "()":
>
> > session = scoped_session(lambda: sessionmaker
> > (bind=application.database_engine)(), local_manager.get_ident)
>
> sessionmaker is a factory function, ie a function that returns a
> function. with sessionmaker(..)() you immediately call the returned
> function (with no arguments in this case).
>
> I do wonder why you need "lambda: sessionmaker(..)()" as an argument
> though? It seems to me it's the same as if you used just "sessionmaker
> (..)" as the first argument.

and seems to work here:

import sqlalchemy
import werkzeug
from sqlalchemy.orm import scoped_session, sessionmaker

sqlite_db = sqlalchemy.create_engine('sqlite:////tmp/foo.db')
local_manager = werkzeug.LocalManager()
session = scoped_session(sessionmaker(bind=sqlite_db),
local_manager.get_ident)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" 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/pocoo-libs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to