[Checkins] SVN: z3c.zalchemy/trunk/src/z3c/zalchemy/ removed repeated table registration by choosing different names

Christian Zagrodnick cz at gocept.com
Thu Nov 30 10:49:48 EST 2006


Log message for revision 71338:
  removed repeated table registration by choosing different names
  
  fixed call to class_mapper

Changed:
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/README.txt
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt

-=-
Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/README.txt
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/README.txt	2006-11-30 14:59:25 UTC (rev 71337)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/README.txt	2006-11-30 15:49:47 UTC (rev 71338)
@@ -50,8 +50,8 @@
 
   >>> import sqlalchemy
   >>> import z3c.zalchemy
-  >>> aTable = sqlalchemy.Table(
-  ...     'aTable',
+  >>> table3 = sqlalchemy.Table(
+  ...     'table3',
   ...     z3c.zalchemy.metadata,
   ...     sqlalchemy.Column('id', sqlalchemy.Integer,
   ...         sqlalchemy.Sequence('atable_id'), primary_key=True),
@@ -66,7 +66,7 @@
 
 Now we map the table to our class.
 
-  >>> sqlalchemy.mapper(A, aTable) is not None
+  >>> sqlalchemy.mapper(A, table3) is not None
   True
 
 To let zalchemy do its work we need to register our database utility.
@@ -78,7 +78,7 @@
 If no session is created then the table creation is deffered to the next
 call to zalchemy.getSession.
 
-  >>> z3c.zalchemy.createTable('aTable')
+  >>> z3c.zalchemy.createTable('table3')
 
 Note that the transaction handling is done inside Zope.
 
@@ -194,7 +194,7 @@
 
   >>> class Aa(object):
   ...     pass
-  >>> sqlalchemy.mapper(Aa, aTable) is not None
+  >>> sqlalchemy.mapper(Aa, table3) is not None
   True
 
 Now we can assign the class to the engine :
@@ -204,7 +204,7 @@
 The problem is now that we do not have the table in 'engine2'.
 We can use an additional parameter to createTable :
 
-  >>> z3c.zalchemy.createTable('aTable', 'engine2')
+  >>> z3c.zalchemy.createTable('table3', 'engine2')
 
   >>> txn = transaction.begin()
 

Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py	2006-11-30 14:59:25 UTC (rev 71337)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py	2006-11-30 15:49:47 UTC (rev 71338)
@@ -120,7 +120,7 @@
 
 def _assignClass(class_, engine):
     if inSession():
-        m = sqlalchemy.orm.session.class_mapper(class_)
+        m = sqlalchemy.orm.class_mapper(class_)
         util = getUtility(IAlchemyEngineUtility, name=engine)
         _storage.session.bind_mapper(m,util.getEngine())
 

Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt	2006-11-30 14:59:25 UTC (rev 71337)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt	2006-11-30 15:49:47 UTC (rev 71338)
@@ -19,8 +19,8 @@
 
   >>> import sqlalchemy
   >>> import z3c.zalchemy
-  >>> aTable = sqlalchemy.Table(
-  ...     'aTable',
+  >>> table2 = sqlalchemy.Table(
+  ...     'table2',
   ...     z3c.zalchemy.metadata,
   ...     sqlalchemy.Column('id', sqlalchemy.Integer,
   ...         sqlalchemy.Sequence('atable_id'), primary_key = True),
@@ -29,7 +29,7 @@
   ...     )
   >>> class A(object):
   ...   pass
-  >>> A.mapper = sqlalchemy.mapper(A, aTable)
+  >>> A.mapper = sqlalchemy.mapper(A, table2)
 
 Now start a zope transaction :
 
@@ -40,7 +40,7 @@
 
   >>> session = z3c.zalchemy.getSession()
 
-  >>> z3c.zalchemy.createTable('aTable')
+  >>> z3c.zalchemy.createTable('table2')
 
 Multiple calls to getSession return the same session :
 



More information about the Checkins mailing list