heres a diff.  the test framework has the "threadlocal" thing turned  
off by default and also plays some games with it.

you should be able to remove all the "save()" statements from the  
tests and everything should keep working; with threadlocal running,  
new objects automatically get added to the session.

also, when you say Item.select(), it looks like youre looking for  
"assign_mapper()" functionality, which tacks on a bunch of methods to  
each class that automatically talk to its mapper; this is something  
of a SQLObject-compatibility hack.  in that case, use assign_mapper 
(class, table) instead of mapper(class, table).

--- /tmp/threadlocal-association.py   2006-06-27 18:55:45.000000000  
-0400
+++ threadlocal-association.py  2006-06-27 19:01:03.000000000 -0400
@@ -2,9 +2,9 @@
from sqlalchemy import *
-
class AssociationTest(testbase.PersistTest):
      def setUpAll(self):
+        self.install_threadlocal()
          global items, item_keywords, keywords, metadata, Item,  
Keyword, KeywordAssociation
          metadata = BoundMetaData(testbase.db)
          items = Table('items', metadata,
@@ -64,8 +64,8 @@
          objectstore.flush()
          saved = repr([item1, item2])
          objectstore.clear()
-#        l = objectstore.query(Item).select()
-        l = Item.select()
+        l = objectstore.query(Item).select()
+#        l = Item.select()
          loaded = repr(l)
          print saved
          print loaded
@@ -84,8 +84,8 @@
          objectstore.flush()
          saved = repr([item1])
          objectstore.clear()
-#        l = objectstore.query(Item).select()
-        l = Item.select()
+        l = objectstore.query(Item).select()
+#        l = Item.select()
          loaded = repr(l)
          print saved
          print loaded

On Jun 27, 2006, at 5:54 PM, Raul Garcia wrote:

> Hello list,
>
> I'm in the process of converting an old SQLObject model to SQLAlchemy.
> To ease the translation process I'm usinf the threadlocal mod, but I'm
> experimenting trouble whwn I use an association object (which I do
> according to the docs).
>
> I'm not sure if I'm doing something wrong; as far as my object  
> model is
> kinda complex, I've modified the unittest for association objects to
> use the threadlocal mod, and none of the test passes (3 errors and 1
> failure, although the failure, in test_delete, is also present in the
> original version of the test).
>
> I use the last svn trunk (r1666), Python 2.4.3 on Windows with sqlite.
> Anyone can help?
>
> Here is the modified association unittest module:
>
>
> Regards,
>
>
> Raúl García.
> <threadlocal-association.py>
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to