[Checkins] SVN: Products.SQLAlchemyDA/trunk/ - using new
'transactional' flag of z3c.sqlalchemy
Andreas Jung
andreas at andreas-jung.com
Sat Jun 9 01:57:49 EDT 2007
Log message for revision 76523:
- using new 'transactional' flag of z3c.sqlalchemy
- new properties 'transactional', 'quoting_style'
Changed:
U Products.SQLAlchemyDA/trunk/CHANGES.txt
U Products.SQLAlchemyDA/trunk/README.txt
U Products.SQLAlchemyDA/trunk/da.py
-=-
Modified: Products.SQLAlchemyDA/trunk/CHANGES.txt
===================================================================
--- Products.SQLAlchemyDA/trunk/CHANGES.txt 2007-06-09 05:50:37 UTC (rev 76522)
+++ Products.SQLAlchemyDA/trunk/CHANGES.txt 2007-06-09 05:57:48 UTC (rev 76523)
@@ -16,6 +16,8 @@
- catching some low-level exceptions from the sqlite interface in order to
make it work with SQLite
+ - new properties 'transactional' and 'quoting_style'
+
0.2.1 (06.05.2007)
- connections can be closed/opened through the ZMI
Modified: Products.SQLAlchemyDA/trunk/README.txt
===================================================================
--- Products.SQLAlchemyDA/trunk/README.txt 2007-06-09 05:50:37 UTC (rev 76522)
+++ Products.SQLAlchemyDA/trunk/README.txt 2007-06-09 05:57:48 UTC (rev 76523)
@@ -22,9 +22,9 @@
- Zope 2.8 +
- - SQLAlchemy 0.3.X (+ database specific low-level Python drivers)
+ - SQLAlchemy 0.3.8 (+ database specific low-level Python drivers)
- - z3c.sqlalchemy 1.0.0 +
+ - z3c.sqlalchemy 1.0.4 +
Installation:
@@ -72,7 +72,20 @@
for details.
+Configuration of SQLAlchemy:
+----------------------------
+ - 'dsn' - SQLAlchemy compliant Database Set Name (see www.sqlalchemy.org/docs)
+
+ - 'transactional' - uncheck this property if you are working with a non-transactional
+ database like older versions of MySQL. Uncheck this property *only* if you see any
+ commit() related error. Otherwise leave this property checked. Changing this
+ property *requires* a Zope restart.
+
+ - 'quoting_style' - affects how strings are quoted in SQL. For using Oracle you might
+ set this to 'oracle', otherwise use the default value 'standard'.
+
+
Using SQLAlchemyDA:
-------------------
Modified: Products.SQLAlchemyDA/trunk/da.py
===================================================================
--- Products.SQLAlchemyDA/trunk/da.py 2007-06-09 05:50:37 UTC (rev 76522)
+++ Products.SQLAlchemyDA/trunk/da.py 2007-06-09 05:57:48 UTC (rev 76523)
@@ -48,10 +48,16 @@
_properties = (
{'id' : 'dsn', 'type' : 'string', 'mode' : 'rw', },
{'id' : 'title', 'type' : 'string', 'mode' : 'rw'},
+ {'id' : 'transactional', 'type' : 'boolean', 'mode' : 'rw'},
+ {'id' : 'quoting_style', 'type' : 'selection', 'mode' : 'rw',
+ 'select_variable' : 'allQuotingStyles'},
)
+
meta_type = 'SQLAlchemyDA '
dsn = ''
+ transactional = True
+ quoting_style = 'standard'
_isAnSQLConnection = True
security = ClassSecurityInfo()
@@ -74,13 +80,19 @@
self.util_id = '%s.%s' % (time.time(), random.random())
+ def allQuotingStyles(self):
+ return ('standard', 'oracle')
+
@property
def _wrapper(self):
if self.dsn:
try:
return getSAWrapper(self.util_id)
except ValueError:
- return createSAWrapper(self.dsn, forZope=True, name=self.util_id)
+ return createSAWrapper(self.dsn,
+ forZope=True,
+ transactional=self.transactional,
+ name=self.util_id)
return None
@@ -196,9 +208,15 @@
def __call__(self, *args, **kv):
return self
-
def sql_quote__(self, s):
- return s
+
+ if self.quoting_style == 'oracle':
+ # oracle style quoting
+ if "\'" in v:
+ v = "''".join(v.split("\'"))
+ return "'%s'" % v
+ else:
+ return s
security.declareProtected(view_management_screens, 'connected')
More information about the Checkins
mailing list