[Checkins] SVN: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/ new 'cascade' parameter for Model.add()

Andreas Jung andreas at andreas-jung.com
Wed May 16 09:45:54 EDT 2007


Log message for revision 75803:
  new 'cascade' parameter for Model.add()
  

Changed:
  U   z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt
  U   z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py
  U   z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/model.py
  U   z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/version.txt

-=-
Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt	2007-05-16 11:13:19 UTC (rev 75802)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/CHANGES.txt	2007-05-16 13:45:54 UTC (rev 75803)
@@ -1,3 +1,7 @@
+1.0.3 (unreleased)
+
+   - new 'cascade' parameter for the Model.add()
+
 1.0.2 (13.05.2007)
 
    - MappedClassBase has a new convinience method getMapper() that returns a

Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py	2007-05-16 11:13:19 UTC (rev 75802)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/mapper.py	2007-05-16 13:45:54 UTC (rev 75803)
@@ -168,7 +168,7 @@
                 table_ref_mapper = self.getMapper(table_refname)
 
                 # add the mapper as relation to the properties dict
-                properties[table_refname] = relation(table_ref_mapper)
+                properties[table_refname] = relation(table_ref_mapper, cascade=self._model.get(name, {}).get('cascade'))
 
             # create a mapper and cache it 
             if mapper_class and mapper_class.__dict__.has_key('c'):

Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/model.py
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/model.py	2007-05-16 11:13:19 UTC (rev 75802)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/model.py	2007-05-16 13:45:54 UTC (rev 75803)
@@ -40,7 +40,7 @@
             self.add(**d)
 
 
-    def add(self, name, table=None, mapper_class=None, relations=None, autodetect_relations=False, table_name=None):
+    def add(self, name, table=None, mapper_class=None, relations=None, autodetect_relations=False, table_name=None, cascade=None):
         """ 'name'  -- name of table (no schema support so far!)
 
             'table' -- a sqlalchemy.Table instance (None, for autoloading)
@@ -56,6 +56,8 @@
 
             'table_name' -- optional full name of a table (e.g. 'someschema.sometable') if
             you want to use 'name' as alias for the table.
+        
+            'cascade' -- cascade parameter directly passed to the relation() call
         """
 
         if table is not None and not isinstance(table, sqlalchemy.Table):
@@ -83,6 +85,7 @@
                       'relations' : relations,
                       'mapper_class' : mapper_class,
                       'autodetect_relations' : autodetect_relations,
+                      'cascade' : cascade,
                       'table_name' : table_name,
                      }
 

Modified: z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/version.txt
===================================================================
--- z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/version.txt	2007-05-16 11:13:19 UTC (rev 75802)
+++ z3c.sqlalchemy/trunk/src/z3c/sqlalchemy/version.txt	2007-05-16 13:45:54 UTC (rev 75803)
@@ -1 +1 @@
-1.0.2
+1.0.3



More information about the Checkins mailing list