]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
make Query._clone() class-agnostic
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Jun 2008 15:32:17 +0000 (15:32 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Jun 2008 15:32:17 +0000 (15:32 +0000)
examples/query_caching/query_caching.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/shard.py

index 1ac8230b6c9076cd3e5a717d9881fcaa9a80edca..fb250acca6b471eae3b7f703e706213ba1e45c2f 100644 (file)
@@ -13,13 +13,6 @@ class CachingQuery(Query):
     def with_cache_key(self, cachekey):
         self.cachekey = cachekey
 
-    # override the _clone() method.   a future release
-    # will just fix _clone() in Query to not hardcode the class so this won't be needed.
-    def _clone(self):
-        q = CachingQuery.__new__(CachingQuery)
-        q.__dict__ = self.__dict__.copy()
-        return q
-
     # single point of object loading is __iter__().  objects in the cache are not associated
     # with a session and are never returned directly; only merged copies.
     def __iter__(self):
index 43f206f38a3ed7ec5bcbbd6bd243b5e4674868ec..700d24d33ce63b846de89193f9283e324d7623cc 100644 (file)
@@ -305,7 +305,8 @@ class Query(object):
         return self
 
     def _clone(self):
-        q = Query.__new__(Query)
+        cls = self.__class__
+        q = cls.__new__(cls)
         q.__dict__ = self.__dict__.copy()
         return q
 
index 6850a0bb07c2b745a4d465cf6d48a63a0855c40e..b4525d8fbf37e6f9a3968a253b5df3d706167271 100644 (file)
@@ -80,11 +80,6 @@ class ShardedQuery(Query):
         self.query_chooser = self.session.query_chooser
         self._shard_id = None
         
-    def _clone(self):
-        q = ShardedQuery.__new__(ShardedQuery)
-        q.__dict__ = self.__dict__.copy()
-        return q
-    
     def set_shard(self, shard_id):
         """return a new query, limited to a single shard ID.