[sqlalchemy] scoped_session(create_session) 0.6

36 views
Skip to first unread message

David Gardner

unread,
May 10, 2010, 12:51:26 PM5/10/10
to sqlal...@googlegroups.com
Not sure if this is a bug or not, but I am not able to call configure()
on a ScopedSession that was created with create_session as it's argument.
I can work around this by using sessionmaker instead, but thought I
should report it as it maybe a bug.

On a side note, I get the same behavior with 0.5.8 and 0.5.6 which leads
me to believe this isn't a bug.
---------------------------

Python 2.6.5 (r265:79063, Apr 20 2010, 19:39:53)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sqlalchemy.orm import scoped_session, create_session
>>> Session = scoped_session(create_session)
>>> Session.configure
<bound method ScopedSession.configure of
<sqlalchemy.orm.scoping.ScopedSession object at 0x171d890>>
>>> Session.configure()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/users/dgardner/src/pcs/branches/pylons/lib/python2.6/site-packages/SQLAlchemy-0.6.0-py2.6.egg/sqlalchemy/orm/scoping.py",
line 87, in configure
self.session_factory.configure(**kwargs)
AttributeError: 'function' object has no attribute 'configure'
>>>

--
David Gardner
Pipeline Tools Programmer
Jim Henson Creature Shop
dgar...@creatureshop.com


--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Michael Bayer

unread,
May 10, 2010, 1:07:07 PM5/10/10
to sqlal...@googlegroups.com
its not a bug. this is why the docs illustrate it using sessionmaker(). If there's some doc that says "it just takes a callable", we should add verbiage that the "configure" process has additional requirements.

David Gardner

unread,
May 10, 2010, 2:27:51 PM5/10/10
to sqlal...@googlegroups.com
Yeah, the docs are confusing on this one:
http://www.sqlalchemy.org/docs/reference/orm/sessions.html?highlight=sessionmaker#sqlalchemy.orm.scoped_session
"Parameters: * session_factory – a callable function that produces
Session instances, such as sessionmaker() or create_session()."

Also I took a peak at the unittests to see if any of them passed
create_session into sessionmaker, and noticed that
test/orm/test_scoping.py uses it.

Michael Bayer

unread,
May 10, 2010, 3:39:17 PM5/10/10
to sqlal...@googlegroups.com
its not a bug to pass create_session to scoped_session either - you just don't get to use configure(). we could even catch the AttributeError here and add friendliness.
Reply all
Reply to author
Forward
0 new messages