Commits

Mike Bayer committed 2daf2bf

0.2.2 prep, added "pickler" option to Pickle type

  • Participants
  • Parent commits abed266

Comments (0)

Files changed (5)

File doc/build/content/document_base.myt

     onepage='documentation'
     index='index'
     title='SQLAlchemy 0.2 Documentation'
-    version = '0.2.0'
+    version = '0.2.2'
 </%attr>
 
 <%method title>

File lib/sqlalchemy/engine/threadlocal.py

             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()

File lib/sqlalchemy/types.py

 
 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
 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",

File test/sql/testtypes.py

 
 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
 
     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
         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):