From: Mike Bayer Date: Mon, 5 Jun 2006 19:18:48 +0000 (+0000) Subject: 0.2.2 prep, added "pickler" option to Pickle type X-Git-Tag: rel_0_2_2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c64bca2143609ca43394bfaad9e67b7cf239688;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 0.2.2 prep, added "pickler" option to Pickle type --- diff --git a/doc/build/content/document_base.myt b/doc/build/content/document_base.myt index db17987d7a..f88a836ffc 100644 --- a/doc/build/content/document_base.myt +++ b/doc/build/content/document_base.myt @@ -24,7 +24,7 @@ onepage='documentation' index='index' title='SQLAlchemy 0.2 Documentation' - version = '0.2.0' + version = '0.2.2' <%method title> diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index 1d99f9ce88..913c6425a2 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -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() diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 65b5d14faf..5fc75678d2 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -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 diff --git a/setup.py b/setup.py index 9baf484b22..292ce5528c 100644 --- 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", diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index f369bd3840..2ec1fe7957 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -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):