diff options
author | Mike Bayer <classic@zzzcomputing.com> | 2016-01-07 12:50:09 -0500 |
---|---|---|
committer | Mike Bayer <classic@zzzcomputing.com> | 2016-01-07 12:50:09 -0500 |
commit | 1539268cf705bff0c7b02814266fc1867dc82d2c (patch) | |
tree | f88e5141f7b66c100c5e99d892d7f4931f1752c2 | |
parent | ff803b1a2a326bad5c7de7810905dee4a1940c81 (diff) | |
parent | a0612a4d345019ea603a4d0bccb4ddcab3848af6 (diff) | |
download | sqlalchemy-1539268cf705bff0c7b02814266fc1867dc82d2c.tar.gz |
Merged in jvanasco/sqlalchemy-alt/issue_docs_scoped_session (pull request #50)
updated docstrings for orm.scoping
-rw-r--r-- | lib/sqlalchemy/orm/scoping.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/scoping.py b/lib/sqlalchemy/orm/scoping.py index b3f2fa5db..176523c3b 100644 --- a/lib/sqlalchemy/orm/scoping.py +++ b/lib/sqlalchemy/orm/scoping.py @@ -21,6 +21,12 @@ class scoped_session(object): """ + session_factory = None + """The `session_factory` provided to `__init__` is stored in this + attribute and may be accessed at a later time. This can be useful when + a new non-scoped :class:`.Session` or :class:`.Connection` to the + database is needed.""" + def __init__(self, session_factory, scopefunc=None): """Construct a new :class:`.scoped_session`. @@ -38,6 +44,7 @@ class scoped_session(object): """ self.session_factory = session_factory + if scopefunc: self.registry = ScopedRegistry(session_factory, scopefunc) else: @@ -45,12 +52,12 @@ class scoped_session(object): def __call__(self, **kw): """Return the current :class:`.Session`, creating it - using the session factory if not present. + using the :attr:`.scoped_session.session_factory` if not present. :param \**kw: Keyword arguments will be passed to the - session factory callable, if an existing :class:`.Session` - is not present. If the :class:`.Session` is present and - keyword arguments have been passed, + :attr:`.scoped_session.session_factory` callable, if an existing + :class:`.Session` is not present. If the :class:`.Session` is present + and keyword arguments have been passed, :exc:`~sqlalchemy.exc.InvalidRequestError` is raised. """ |