server/sqlutils.py
branchtls-sprint
changeset 1263 01152fffd593
parent 1132 96752791c2b6
parent 1251 af40e615dc89
child 1408 6bf19f175ea5
--- a/server/sqlutils.py	Mon Apr 06 12:37:45 2009 +0200
+++ b/server/sqlutils.py	Tue Apr 07 09:30:23 2009 +0200
@@ -21,7 +21,10 @@
 from cubicweb.server import SQL_CONNECT_HOOKS
 from cubicweb.server.utils import crypt_password
 
+
 db.USE_MX_DATETIME = False
+SQL_PREFIX = 'cw_'
+
 
 def sqlexec(sqlstmts, cursor_or_execute, withpb=True, delimiter=';'):
     """execute sql statements ignoring DROP/ CREATE GROUP or USER statements
@@ -62,7 +65,7 @@
         indexer = get_indexer(driver)
         w(indexer.sql_grant_user(user))
         w('')
-    w(grant_schema(schema, user, set_owner, skip_entities=skip_entities))
+    w(grant_schema(schema, user, set_owner, skip_entities=skip_entities, prefix=SQL_PREFIX))
     return '\n'.join(output)
 
                   
@@ -83,7 +86,7 @@
         w(indexer.sql_init_fti())
         w('')
     dbhelper = get_adv_func_helper(driver)
-    w(schema2sql(dbhelper, schema, 
+    w(schema2sql(dbhelper, schema, prefix=SQL_PREFIX, 
                  skip_entities=skip_entities, skip_relations=skip_relations))
     if dbhelper.users_support and user:
         w('')
@@ -105,7 +108,7 @@
         indexer = get_indexer(driver)
         w(indexer.sql_drop_fti())
         w('')
-    w(dropschema2sql(schema,
+    w(dropschema2sql(schema, prefix=SQL_PREFIX,
                      skip_entities=skip_entities, skip_relations=skip_relations))
     return '\n'.join(output)
 
@@ -196,7 +199,7 @@
 
     def preprocess_entity(self, entity):
         """return a dictionary to use as extra argument to cursor.execute
-        to insert/update an entity
+        to insert/update an entity into a SQL database
         """
         attrs = {}
         eschema = entity.e_schema
@@ -215,7 +218,7 @@
                         value = crypt_password(value)
                 elif isinstance(value, Binary):
                     value = self.binary(value.getvalue())
-            attrs[str(attr)] = value
+            attrs[SQL_PREFIX+str(attr)] = value
         return attrs