--- a/iro/model/utils.py Thu Mar 29 16:27:40 2012 +0200
+++ b/iro/model/utils.py Thu Mar 29 17:21:46 2012 +0200
@@ -1,15 +1,22 @@
from sqlalchemy.orm import sessionmaker
from .session import IroSession
+class WithSession(object):
+ '''a with statement for a database session connection.'''
+ 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.
-class WithSession(object):
- '''a with statement for a database session connection'''
- def __init__(self, engine, autocommit=False):
+ .. automethod:: __enter__
+ """
self.engine = engine
self.autocommit=autocommit
def __enter__(self):
self.session = sessionmaker(bind=self.engine, class_ = IroSession)()
+ """returns a vaild session object"""
+ self.session = sessionmaker(bind=self.engine)()
return self.session
def __exit__(self,exc_type, exc_value, traceback):