]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
0.2.2 prep, added "pickler" option to Pickle type
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Jun 2006 19:18:48 +0000 (19:18 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Jun 2006 19:18:48 +0000 (19:18 +0000)
doc/build/content/document_base.myt
lib/sqlalchemy/engine/threadlocal.py
lib/sqlalchemy/types.py
setup.py
test/sql/testtypes.py

index db17987d7a9beeb03e56703238a8c4a74602adb8..f88a836ffc065298858e33ebdc7ce919ceb68df1 100644 (file)
@@ -24,7 +24,7 @@
     onepage='documentation'
     index='index'
     title='SQLAlchemy 0.2 Documentation'
-    version = '0.2.0'
+    version = '0.2.2'
 </%attr>
 
 <%method title>
index 1d99f9ce88279ab72d1cf78ceb79b91584c9e330..913c6425a29c48c255fd1e4a4ed3b4dd9d949331 100644 (file)
@@ -15,11 +15,6 @@ class TLSession(object):
             return self.__transaction._increment_connect()
         except AttributeError:
             return TLConnection(self, close_with_result=close_with_result)
-    def set_transaction(self, tlconnection, trans):
-        if self.__tcount == 0:
-            self.__transaction = tlconnection
-            self.__trans = trans
-        self.__tcount += 1
     def reset(self):
         try:
             self.__transaction._force_close()
index 65b5d14faf2db2e62e47dcd1cf6bc6369cec1d65..5fc75678d2fe087667b4ccb6a293f40fc50a2cb8 100644 (file)
@@ -199,19 +199,19 @@ class Binary(TypeEngine):
 
 class PickleType(TypeDecorator):
     impl = Binary
-    def __init__(self, protocol=pickle.HIGHEST_PROTOCOL):
-       """allows the pickle protocol to be specified"""
+    def __init__(self, protocol=pickle.HIGHEST_PROTOCOL, pickler=None):
        self.protocol = protocol
+       self.pickler = pickler or pickle
        super(PickleType, self).__init__()
     def convert_result_value(self, value, dialect):
       if value is None:
           return None
       buf = self.impl.convert_result_value(value, dialect)
-      return pickle.loads(str(buf))
+      return self.pickler.loads(str(buf))
     def convert_bind_param(self, value, dialect):
       if value is None:
           return None
-      return self.impl.convert_bind_param(pickle.dumps(value, self.protocol), dialect)
+      return self.impl.convert_bind_param(self.pickler.dumps(value, self.protocol), dialect)
 
 class Boolean(TypeEngine):
     pass
index 9baf484b22fc4df1bf563194b4ef135dbbce6026..292ce5528c0fee96f8dfc730892b1f69b901f961 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@ use_setuptools()
 from setuptools import setup, find_packages
 
 setup(name = "SQLAlchemy",
-    version = "0.2.1",
+    version = "0.2.2",
     description = "Database Abstraction Library",
     author = "Mike Bayer",
     author_email = "mike_mp@zzzcomputing.com",
index f369bd384040c7c33014c9807116f777ad5292c7..2ec1fe7957896afe0f88c99b55a9010d3c3e8fd5 100644 (file)
@@ -6,11 +6,6 @@ import sqlalchemy.engine.url as url
 
 import sqlalchemy.types
 
-# TODO: cant get cPickle to pickle the "Foo" class from this module,
-# now that its moved
-import pickle
-sqlalchemy.types.pickle = pickle
-
 
 db = testbase.db
 
@@ -177,6 +172,8 @@ class Foo(object):
     def __eq__(self, other):
         return other.data == self.data and other.stuff == self.stuff and other.moredata==self.moredata
 
+import pickle
+
 class BinaryTest(AssertMixin):
     def setUpAll(self):
         global binary_table
@@ -185,7 +182,10 @@ class BinaryTest(AssertMixin):
         Column('data', Binary),
         Column('data_slice', Binary(100)),
         Column('misc', String(30)),
-        Column('pickled', PickleType)
+        # construct PickleType with non-native pickle module, since cPickle uses relative module
+        # loading and confuses this test's parent package 'sql' with the 'sqlalchemy.sql' package relative
+       # to the 'types' module
+        Column('pickled', PickleType(pickler=pickle))
         )
         binary_table.create()
     def tearDownAll(self):