[Checkins] SVN: z3c.zalchemy/sandbox/src/z3c/zalchemy/ added
convert_unicode to engine directive
Bernd Dorn
bernd.dorn at fhv.at
Mon Apr 24 06:35:52 EDT 2006
Log message for revision 67562:
added convert_unicode to engine directive
Changed:
U z3c.zalchemy/sandbox/src/z3c/zalchemy/datamanager.py
U z3c.zalchemy/sandbox/src/z3c/zalchemy/metaconfigure.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 07:27:33 UTC (rev 67561)
+++ z3c.zalchemy/sandbox/src/z3c/zalchemy/datamanager.py 2006-04-24 10:35:52 UTC (rev 67562)
@@ -33,11 +33,12 @@
implements(IAlchemyEngineUtility)
def __init__(self, name, dns, echo=False, encoding=u'utf-8',
- **kwargs):
+ convert_unicode=False, **kwargs):
self.name = name
self.dns = dns
self.echo = echo
self.encoding=encoding or None
+ self.convert_unicode=convert_unicode or False
self.kw=kwargs
self.tables = []
self.storage = local()
@@ -59,9 +60,10 @@
"""tries to create the given table if not there"""
self.connectTablesForThread()
- #table.engine.connect(self.dns,self.kw,echo=self.echo)
- #table.engine.engine = self.storage.engine
- table.create()
+ try:
+ table.create()
+ except sqlalchemy.exceptions.SQLError,e:
+ return
# seems that this does not get commited, why?
objectstore.commit()
#self.dataManagerFinished()
@@ -75,10 +77,9 @@
engine=getattr(self.storage,'engine',None)
if engine is not None:
return False
- self.storage.engine = create_engine(self.dns,
- self.kw,
- echo=self.echo,
- encoding=self.encoding)
+ self.storage.engine = create_engine(
+ self.dns, self.kw, echo=self.echo,
+ encoding=self.encoding, convert_unicode=self.convert_unicode)
return True
def connectTablesForThread(self):
Modified: z3c.zalchemy/sandbox/src/z3c/zalchemy/metaconfigure.py
===================================================================
--- z3c.zalchemy/sandbox/src/z3c/zalchemy/metaconfigure.py 2006-04-24 07:27:33 UTC (rev 67561)
+++ z3c.zalchemy/sandbox/src/z3c/zalchemy/metaconfigure.py 2006-04-24 10:35:52 UTC (rev 67562)
@@ -17,9 +17,12 @@
from datamanager import AlchemyEngineUtility
from interfaces import IAlchemyEngineUtility
-def engine(_context, name, dns, echo=False, encoding=u'utf-8', **kwargs):
+def engine(_context, name, dns, echo=False, encoding=u'utf-8',
+ convert_unicode=False,**kwargs):
component = AlchemyEngineUtility(name, dns, echo=echo,
- encoding=encoding,**kwargs)
+ encoding=encoding,
+ convert_unicode=convert_unicode,
+ **kwargs)
utility(_context,
IAlchemyEngineUtility,
component,
Modified: z3c.zalchemy/sandbox/src/z3c/zalchemy/metadirectives.py
===================================================================
--- z3c.zalchemy/sandbox/src/z3c/zalchemy/metadirectives.py 2006-04-24 07:27:33 UTC (rev 67561)
+++ z3c.zalchemy/sandbox/src/z3c/zalchemy/metadirectives.py 2006-04-24 10:35:52 UTC (rev 67562)
@@ -32,6 +32,20 @@
default=False
)
+ convert_unicode = Bool(title = u'Convert Unicode',
+ description=u"""If set to True, all String/character based
+ types will convert Unicode values to raw
+ byte values going into the database, and
+ all raw byte values to Python Unicode
+ coming out in result sets. This is an
+ engine-wide method to provide unicode
+ across the board. For unicode conversion on
+ a column-by-column level, use the Unicode
+ column type instead.""",
+ required = False,
+ default=False
+ )
+
encoding = schema.TextLine(title=u'Encoding',
default=u'utf-8',
required=False)
Modified: z3c.zalchemy/sandbox/src/z3c/zalchemy/tests/test_directives.py
===================================================================
--- z3c.zalchemy/sandbox/src/z3c/zalchemy/tests/test_directives.py 2006-04-24 07:27:33 UTC (rev 67561)
+++ z3c.zalchemy/sandbox/src/z3c/zalchemy/tests/test_directives.py 2006-04-24 10:35:52 UTC (rev 67562)
@@ -33,12 +33,14 @@
echo="True"
filename="testdatabase.db"
encoding="ISO-8859-15"
+ convert_unicode="True"
/>
'''
)))
util = component.getUtility(IAlchemyEngineUtility,'sqlite')
self.assertNotEqual(util, None)
self.assertEqual(util.dns, 'sqlite')
+ self.assertEqual(util.convert_unicode, True)
self.assertEqual(util.echo, True)
self.assertEqual(util.encoding, 'ISO-8859-15')
self.assertEqual(util.kw['filename'], 'testdatabase.db')
More information about the Checkins
mailing list