iro/model/dbdefer.py
branchdevel
changeset 258 0a5eb5aac0be
parent 155 ff1edf7c1329
child 294 0e75bd39767d
--- a/iro/model/dbdefer.py	Thu Mar 29 13:46:37 2012 +0200
+++ b/iro/model/dbdefer.py	Thu Mar 29 16:27:40 2012 +0200
@@ -7,8 +7,16 @@
 import inspect
 
 class DBDefer(object):
-    '''a twisted sqlalchemy connector this Decorator adds a session parameter, with a valid session connection'''
+    '''a twisted sqlalchemy connector.
+    
+    This is used as a Decorator class.
+    It adds a session parameter to the function with a valid session.
+    If the session parmaeter is used in calling this function only calls a commit after running the function, instead of createing a new session.'''
     def __init__(self, engine, autocommit=False):
+        """
+        :param `sqlalchemy.engine.base.Engine` engine: a valid sqlalchemy engine object (normally created via :func:`sqlalchemy.create_engine`).
+        :param boolean autocommit: autocommit after running the function.
+        """
         self.autocommit=autocommit
         self.engine = engine
 
@@ -53,8 +61,10 @@
         return wrap
 
 dbdefer=DBDefer(None)
+"""the decorator to use. Use :func:`setEngine` to set a valid engine after program has started."""
 
 def setEngine(engine,autocommit=False): 
+    """set the engine and autocommit for the decorator (see :class:`DBDefer`)."""
     dbdefer.engine = engine
     dbdefer.autocommit = autocommit