[Checkins] SVN: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/ passing **kw to the constructor

Andreas Jung andreas at andreas-jung.com
Sat Apr 14 07:39:43 EDT 2007


Log message for revision 74130:
  passing **kw to the constructor
  

Changed:
  U   z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py
  U   z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/util.py

-=-
Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py	2007-04-14 11:37:35 UTC (rev 74129)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/base.py	2007-04-14 11:39:43 UTC (rev 74130)
@@ -27,12 +27,12 @@
 
     implements(ISQLAlchemyWrapper)
 
-    def __init__(self, dsn, model=None, echo=False):
+    def __init__(self, dsn, model=None, **kw):
         """ 'dsn' - a RFC-1738-style connection string
 
             'model' - optional instance of model.Model
 
-            'echo' - output generated SQL commands
+            'kw' - optional keyword arguments passed to create_engine()
         """
 
         self.dsn = dsn
@@ -43,9 +43,10 @@
         self.password = self.url.password
         self.dbname = self.url.database 
         self.drivername = self.url.drivername
-        self.echo = echo
+        self.kw = kw
+        self.echo = kw.get('echo', False)
         self._engine = self._createEngine()
-        self._engine.echo = echo
+        self._engine.echo = self.echo
         self._model = None
 
         if model:
@@ -95,7 +96,7 @@
         return self._model
 
     def _createEngine(self):
-        return sqlalchemy.create_engine(self.dsn)
+        return sqlalchemy.create_engine(self.dsn, **self.kw)
 
 
 _cache = threading.local() # module-level cache 

Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/util.py
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/util.py	2007-04-14 11:37:35 UTC (rev 74129)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/util.py	2007-04-14 11:39:43 UTC (rev 74130)
@@ -26,7 +26,7 @@
 __all__ = ('createSQLAlchemyWrapper', 'registerSQLAlchemyWrapper', 'allRegisteredSQLAlchemyWrappers')
 
 
-def createSQLAlchemyWrapper(dsn, model=None, echo=False, forZope=False):
+def createSQLAlchemyWrapper(dsn, model=None, forZope=False, **kw):
     """ Convenience method to generate a wrapper for a DSN and a model.
         This method hides all database related magic from the user. 
         Set 'forZope' to True for a Zope related wrapper.
@@ -40,7 +40,7 @@
     if driver == 'postgres':
         klass = forZope and ZopePostgresWrapper or PythonPostgresWrapper
 
-    return klass(dsn, echo=echo, model=model)
+    return klass(dsn, model, **kw)
 
 
 def registerSQLAlchemyWrapper(wrapper, name):



More information about the Checkins mailing list