]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
document "Accessing the Session"
authorJonathan Ellis <jbellis@gmail.com>
Wed, 17 Jan 2007 18:25:37 +0000 (18:25 +0000)
committerJonathan Ellis <jbellis@gmail.com>
Wed, 17 Jan 2007 18:25:37 +0000 (18:25 +0000)
lib/sqlalchemy/ext/sqlsoup.py

index d3081bc237d3256b9c6e731fbcd6d15e5a77ba10..7b0a5759df71021c111cfa665999588f9d43e8b5 100644 (file)
@@ -163,6 +163,21 @@ to disambiguate columns with their table name:
 Advanced Use
 ============
 
+Accessing the Session
+---------------------
+
+SqlSoup uses a SessionContext to provide thread-local sessions.  You can
+get a reference to the current one like this:
+
+    >>> from sqlalchemy.ext.sqlsoup import objectstore
+    >>> session = objectstore.current
+
+Now you have access to all the standard session-based SA features, such
+as transactions.  (SqlSoup's flush() is normally transactionalized, but
+you can perform manual transaction management if you need a transaction
+to span multiple flushes.)
+
+
 Mapping arbitrary Selectables
 -----------------------------
 
@@ -336,7 +351,7 @@ def _selectable_name(selectable):
 def class_for_table(selectable, **mapper_kwargs):
     if not hasattr(selectable, '_selectable') \
     or selectable._selectable() != selectable:
-        raise 'class_for_table requires a selectable as its argument'
+        raise ArgumentError('class_for_table requires a selectable as its argument')
     mapname = 'Mapped' + _selectable_name(selectable)
     klass = TableClassType(mapname, (object,), {})
     def __cmp__(self, o):