]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
(no commit message)
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 16 Sep 2005 06:34:21 +0000 (06:34 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 16 Sep 2005 06:34:21 +0000 (06:34 +0000)
lib/sqlalchemy/util.py
test/mapper.py

index de252f44ce150159aef2166ef86194ebadd6e805..6f2478a92ff3d11b15657a9d77cefe327f309423 100644 (file)
@@ -149,6 +149,8 @@ class HistoryArraySet(UserList.UserList):
                del self.data[i]
                i -= 1
 
+    def hash(self):
+        return id(self)
     def _setrecord(self, item):
         try:
             val = self.records[item]
@@ -272,8 +274,8 @@ class ScopedRegistry(object):
         self.application = createfunc()
         self.threadlocal = {}
         self.scopes = {
-                    'application' : {'call' : self._call_application, 'clear' : self._clear_application}, 
-                    'thread' : {'call' : self._call_thread, 'clear':self._clear_thread}
+                    'application' : {'call' : self._call_application, 'clear' : self._clear_application, 'set':self._set_application}, 
+                    'thread' : {'call' : self._call_thread, 'clear':self._clear_thread, 'set':self._set_thread}
                     }
 
     def __call__(self, scope = None):
@@ -281,11 +283,19 @@ class ScopedRegistry(object):
             scope = self.defaultscope
         return self.scopes[scope]['call']()
 
+    def set(self, obj, scope = None):
+        if scope is None:
+            scope = self.defaultscope
+        return self.scopes[scope]['set'](obj)
+        
     def clear(self, scope = None):
         if scope is None:
             scope = self.defaultscope
         return self.scopes[scope]['clear']()
-        
+
+    def _set_thread(self, obj):
+        self.threadlocal[thread.get_ident()] = obj
+    
     def _call_thread(self):
         try:
             return self.threadlocal[thread.get_ident()]
@@ -298,6 +308,9 @@ class ScopedRegistry(object):
         except KeyError:
             pass
 
+    def _set_application(self, obj):
+        self.application = obj
+        
     def _call_application(self):
         return self.application
 
index 46cc211a896265ab09d7f093de5c3ae5b2d86d3c..a9b5a40bfffd3f069ede71248d091b0182095706 100644 (file)
@@ -317,20 +317,30 @@ class SaveTest(AssertMixin):
         # assert the first one retreives the same from the identity map
         nu = m.get(u.user_id)
         self.assert_(u is nu)
-
+        
+        print "STEP 1"
+        print repr(objectstore.identity_map)
+        
         # clear out the identity map, so next get forces a SELECT
         objectstore.clear()
 
+        print "STEP 2"
+        print repr(objectstore.identity_map)
+
         # check it again, identity should be different but ids the same
         nu = m.get(u.user_id)
         self.assert_(u is not nu and u.user_id == nu.user_id and nu.user_name == 'savetester')
 
         # change first users name and save
         u.user_name = 'modifiedname'
+        print "STEP 3"
+        print repr(objectstore.identity_map)
         objectstore.uow().commit()
 
         # select both
+        #objectstore.clear()
         userlist = m.select(users.c.user_id.in_(u.user_id, u2.user_id), order_by=[users.c.user_name])
+        print repr(userlist)
         # making a slight assumption here about the IN clause mechanics with regards to ordering
         self.assert_(u.user_id == userlist[0].user_id and userlist[0].user_name == 'modifiedname')
         self.assert_(u2.user_id == userlist[1].user_id and userlist[1].user_name == 'savetester2')