[Checkins] SVN: z3c.saconfig/trunk/src/z3c/saconfig/ Do not enable convert_unicode by default. This option changes standard
Wichert Akkerman
wichert at wiggy.net
Tue Aug 11 14:54:22 EDT 2009
Log message for revision 102681:
Do not enable convert_unicode by default. This option changes standard
SQLAlchemy behaviour by making String type columns return unicode data.
This can be especially painful in Zope2 environments where unicode is
not always accepted.
Add a convert_unicode option to the zcml engine statement, allowing
people who need convert_unicode to enable it.
Changed:
U z3c.saconfig/trunk/src/z3c/saconfig/README.txt
U z3c.saconfig/trunk/src/z3c/saconfig/utility.py
U z3c.saconfig/trunk/src/z3c/saconfig/zcml.py
-=-
Modified: z3c.saconfig/trunk/src/z3c/saconfig/README.txt
===================================================================
--- z3c.saconfig/trunk/src/z3c/saconfig/README.txt 2009-08-11 18:36:59 UTC (rev 102680)
+++ z3c.saconfig/trunk/src/z3c/saconfig/README.txt 2009-08-11 18:54:22 UTC (rev 102681)
@@ -68,9 +68,7 @@
>>> engine_factory = EngineFactory(TEST_DSN)
You can pass the parameters you'd normally pass to
-``sqlalchemy.create_engine`` to ``EngineFactory``. Note that
-``z3c.saconfig`` assumes ``convert_unicode`` to be ``True`` by
-default.
+``sqlalchemy.create_engine`` to ``EngineFactory``.
We now register the engine factory as a global utility using
``zope.component``. Normally you'd use either ZCML or Grok to do this
Modified: z3c.saconfig/trunk/src/z3c/saconfig/utility.py
===================================================================
--- z3c.saconfig/trunk/src/z3c/saconfig/utility.py 2009-08-11 18:36:59 UTC (rev 102680)
+++ z3c.saconfig/trunk/src/z3c/saconfig/utility.py 2009-08-11 18:54:22 UTC (rev 102681)
@@ -125,8 +125,6 @@
EngineFactory should be registered as a local utility in that
site.
- convert_unicode is True by default.
-
If you want this utility to be persistent, you should subclass it
and mixin Persistent. You could then manage the parameters
differently than is done in this __init__, for instance as
@@ -136,8 +134,6 @@
implements(IEngineFactory)
def __init__(self, *args, **kw):
- if 'convert_unicode' not in kw:
- kw['convert_unicode'] = True
self._args = args
self._kw = kw
self._key = self._getKey()
Modified: z3c.saconfig/trunk/src/z3c/saconfig/zcml.py
===================================================================
--- z3c.saconfig/trunk/src/z3c/saconfig/zcml.py 2009-08-11 18:36:59 UTC (rev 102680)
+++ z3c.saconfig/trunk/src/z3c/saconfig/zcml.py 2009-08-11 18:54:22 UTC (rev 102681)
@@ -21,6 +21,15 @@
required=False,
default=u"")
+ convert_unicode = zope.schema.Bool(
+ title=u'Convert all string columns to unicode',
+ description=u'This setting makes the SQLAlchemy String column type '
+ u'equivalent to UnicodeString. Do not use this unless '
+ u'there is a good reason not to use standard '
+ u'UnicodeString columns',
+ required=False,
+ default=False)
+
echo = zope.schema.Bool(
title=u'Echo SQL statements',
description=u'Enable logging statements for debugging.',
@@ -62,9 +71,9 @@
default="z3c.saconfig.utility.GloballyScopedSession")
-def engine(_context, url, name=u"", echo=False, setup=None, twophase=False):
+def engine(_context, url, name=u"", convert_unicode=False, echo=False, setup=None, twophase=False):
factory = utility.EngineFactory(
- url, echo=echo)
+ url, echo=echo, convert_unicode=convert_unicode)
zope.component.zcml.utility(
_context,
More information about the Checkins
mailing list