diff ZDBInterfaceFolder.py @ 8:17b19345d011

added autocommit option.
author casties
date Thu, 17 Feb 2011 19:25:16 +0100
parents 917e28a08c58
children 87087f4f4059
line wrap: on
line diff
--- a/ZDBInterfaceFolder.py	Tue Feb 15 21:14:03 2011 +0100
+++ b/ZDBInterfaceFolder.py	Thu Feb 17 19:25:16 2011 +0100
@@ -26,13 +26,13 @@
     manage_editZDBInterfaceFolderForm=PageTemplateFile('zpt/editZDBInterfaceFolder',globals())
 
     
-    def __init__(self, id, title, connection_id=None):
+    def __init__(self, id, title, connection_id=None, autocommit=False):
         """init"""
         self.id = id
         self.title = title
         # database connection id
         self.connection_id = connection_id
-
+        self.autocommit = autocommit
 
     def getSQLQuery(self, table, argv):
         """returns dict with SQL query string and args"""
@@ -42,7 +42,8 @@
         order = None
         wheres = []
         whereOp = "AND"
-        done = {}
+        processed = {}
+        unprocessed = {}
         limit = None
         offset = None
 
@@ -95,7 +96,7 @@
 
         # evaluate argv
         for (key, val) in argv.items():
-            if key in done:
+            if key in processed:
                 # parameter has been processed
                 continue
             
@@ -124,17 +125,19 @@
                 logging.debug("param=%s key=%s val=%s"%(param,key,val))
                 if param in argv:
                     doOp(val, param, argv[param])
-                    done[param] = True
+                    processed[param] = True
                 else:
                     # no corresponding parameter
                     logging.error("getSQLquery: param=%s for op not found!"%param)
+            else:
+                # parameter=value pair
+                unprocessed[key] = val
                 
         # process remaining parameters (without _op)
-        for (key, val) in argv.items():
-            if key not in done and key[0] not in ("_", "-"):
-                param = sqlName(key)
-                # default is begins-with
-                doOp("bw", param, val)
+        for (key, val) in unprocessed.items():
+            param = sqlName(key)
+            # default is begins-with
+            doOp("bw", param, val)
 
         # join it all
         query = "SELECT %s FROM %s"%(select, table)
@@ -158,15 +161,18 @@
         result = self.executeZSQL(query['query'], query['args'])
         return result
     
-    def manage_editZDBInterfaceFolder(self, title=None, connection_id=None,
+    def manage_editZDBInterfaceFolder(self, title=None, connection_id=None, autocommit=None,
                      REQUEST=None):
         """Change the object"""
+        logging.debug("editZDBInterfaceFolder title=%s, connection_id=%s, autocommit=%s"%(title,connection_id,autocommit))
         if title is not None:
             self.title = title
             
         if connection_id is not None:
             self.connection_id = connection_id
                 
+        self.autocommit = (autocommit == "on")
+                
         #checkPermission=getSecurityManager().checkPermission
         REQUEST.RESPONSE.redirect('manage_main')