]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
reduce cruft related to serializable loaders
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 12 Oct 2008 05:13:46 +0000 (05:13 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 12 Oct 2008 05:13:46 +0000 (05:13 +0000)
lib/sqlalchemy/orm/strategies.py

index 7439ab68b774b1ed661898aabf62c2b74d9edf86..3c156b70f24f6f7fed6df7405ff87262d60fc2e2 100644 (file)
@@ -222,23 +222,9 @@ log.class_logger(DeferredColumnLoader)
 class LoadDeferredColumns(object):
     """serializable loader object used by DeferredColumnLoader"""
     
-    def __init__(self, state, key, keys):
-        self.state = state
-        self.key = key
-        self.keys = keys
+    def __init__(self, *args):
+        self.state, self.key, self.keys = args
 
-    def __getstate__(self):
-        return {
-            'state':self.state, 
-            'key':self.key, 
-            'keys':self.keys
-        }
-    
-    def __setstate__(self, state):
-        self.state = state['state']
-        self.key = state['key']
-        self.keys = state['keys']
-        
     def __call__(self):
         state = self.state
         
@@ -502,25 +488,15 @@ log.class_logger(LazyLoader)
 class LoadLazyAttribute(object):
     """serializable loader object used by LazyLoader"""
 
-    def __init__(self, state, key, options, path):
-        self.state = state
-        self.key = key
-        self.options = options
-        self.path = path
+    def __init__(self, *args):
+        self.state, self.key, self.options, self.path = args
         
     def __getstate__(self):
-        return {
-            'state':self.state, 
-            'key':self.key, 
-            'options':self.options, 
-            'path':serialize_path(self.path)
-        }
+        return (self.state, self.key, self.options, serialize_path(self.path))
 
     def __setstate__(self, state):
-        self.state = state['state']
-        self.key = state['key']
-        self.options = state['options']
-        self.path = deserialize_path(state['path'])
+        self.state, self.key, self.options, path = state
+        self.path = deserialize_path(path)
         
     def __call__(self):
         state = self.state