[Checkins] SVN: z3c.zalchemy/sandbox/src/z3c/zalchemy/ added encoding to engine directive

Bernd Dorn bernd.dorn at fhv.at
Mon Apr 24 02:06:43 EDT 2006


Log message for revision 67560:
  added encoding to engine directive

Changed:
  U   z3c.zalchemy/sandbox/src/z3c/zalchemy/datamanager.py
  U   z3c.zalchemy/sandbox/src/z3c/zalchemy/metadirectives.py
  U   z3c.zalchemy/sandbox/src/z3c/zalchemy/tests/test_directives.py

-=-
Modified: z3c.zalchemy/sandbox/src/z3c/zalchemy/datamanager.py
===================================================================
--- z3c.zalchemy/sandbox/src/z3c/zalchemy/datamanager.py	2006-04-24 05:00:45 UTC (rev 67559)
+++ z3c.zalchemy/sandbox/src/z3c/zalchemy/datamanager.py	2006-04-24 06:06:42 UTC (rev 67560)
@@ -31,11 +31,12 @@
     """A utility providing the dns for alchemy database engines.
     """
     implements(IAlchemyEngineUtility)
-
-    def __init__(self, name, dns, echo=False, **kwargs):
+    
+    def __init__(self, name, dns, echo=False, encoding=None, **kwargs):
         self.name = name
         self.dns = dns
         self.echo = echo
+        self.encoding=encoding or None
         self.kw=kwargs
         self.tables = []
         self.storage = local()
@@ -75,7 +76,8 @@
             return False
         self.storage.engine = create_engine(self.dns,
                                             self.kw,
-                                            echo=self.echo)
+                                            echo=self.echo,
+                                            encoding=self.encoding)
         return True
 
     def connectTablesForThread(self):

Modified: z3c.zalchemy/sandbox/src/z3c/zalchemy/metadirectives.py
===================================================================
--- z3c.zalchemy/sandbox/src/z3c/zalchemy/metadirectives.py	2006-04-24 05:00:45 UTC (rev 67559)
+++ z3c.zalchemy/sandbox/src/z3c/zalchemy/metadirectives.py	2006-04-24 06:06:42 UTC (rev 67560)
@@ -19,20 +19,23 @@
 class IEngineDirective(interface.Interface):
     """Define an engine.
     """
-    name = schema.Text(
-            title = u'Engine name',
-            required = True,
-            )
-    dns = schema.Text(
-            title = u'DNS for the database connection',
-            required = True,
-            )
-    echo = schema.Bool(
-            title = u'Echo SQL statement',
-            required = False,
-            default=False
-            )
+    name = schema.TextLine(title = u'Engine name',
+                           required = True,
+                           )
+    
+    dns = schema.TextLine(title = u'DNS for the database connection',
+                          required = True,
+                          )
+    
+    echo = Bool(title = u'Echo SQL statement',
+                required = False,
+                default=False
+                )
 
+    encoding = schema.TextLine(title=u'Encoding',
+                               default=None,
+                               required=False)
+
 # Arbitrary keys and values are allowed to be passed to the viewlet.
 IEngineDirective.setTaggedValue('keyword_arguments', True)
 

Modified: z3c.zalchemy/sandbox/src/z3c/zalchemy/tests/test_directives.py
===================================================================
--- z3c.zalchemy/sandbox/src/z3c/zalchemy/tests/test_directives.py	2006-04-24 05:00:45 UTC (rev 67559)
+++ z3c.zalchemy/sandbox/src/z3c/zalchemy/tests/test_directives.py	2006-04-24 06:06:42 UTC (rev 67560)
@@ -32,6 +32,7 @@
                 dns="sqlite"
                 echo="True"
                 filename="testdatabase.db"
+                encoding="ISO-8859-15"
                 />
             '''
             )))
@@ -39,6 +40,7 @@
         self.assertNotEqual(util, None)
         self.assertEqual(util.dns, 'sqlite')
         self.assertEqual(util.echo, True)
+        self.assertEqual(util.encoding, 'ISO-8859-15')
         self.assertEqual(util.kw['filename'], 'testdatabase.db')
 
     def testConnectDirective(self):



More information about the Checkins mailing list