[SQL-CVS] SQLObject development repository branch master updated. 2.1.0-216-g894a92f
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Oleg B. <no...@so...> - 2015-02-16 16:34:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "SQLObject development repository". The branch, master has been updated via 894a92f5b1eda6e2aad174ac34b24971ffdd3008 (commit) via ff7d207b77a6d9dbab1f7076574b978564dd25c7 (commit) via eb878a622e05d0c703d5433c2ddf18a4799cb680 (commit) via 4414ff1f2b1d142dfb3115b2f3336e2ebe7b4aa9 (commit) via fbd179e40cd4c293a604b7830a320aa8e1af5bf1 (commit) via 7e955f802a8c426894790df3534130b423ef61ba (commit) via aafa59cac20f6686859e11b85cc14eb0213b44f9 (commit) via 056fd5398af45742abee0d419c8687d76c443569 (commit) via c962c5ea401c74343becc23ad0842c3918ec7414 (commit) via 85cc5fe77c7dc412b2a4ed5bc7dcda51ea37cb97 (commit) via 4513d2e88d0527665f6b49ab66ea30a27e7c2040 (commit) via 9e74a80a3abfa69fffae00bea644f2d5b239be00 (commit) via 71df75e74879b273fd861afd39e030d618baeb57 (commit) via d5612ab75b6556f7f041eb31c2541acf649ff7a4 (commit) from fce408b71883cfbafada9c38c3c07328384357ec (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://sourceforge.net/p/sqlobject/sqlobject/ci/894a92f5b1eda6e2aad174ac34b24971ffdd3008 commit 894a92f5b1eda6e2aad174ac34b24971ffdd3008 Merge: ff7d207 fbd179e Author: Oleg Broytman <ph...@ph...> Date: Mon Feb 16 19:33:19 2015 +0300 Merge pull request #84 from drnlm/py3k_fixes Py3k fixes http://sourceforge.net/p/sqlobject/sqlobject/ci/ff7d207b77a6d9dbab1f7076574b978564dd25c7 commit ff7d207b77a6d9dbab1f7076574b978564dd25c7 Merge: fce408b eb878a6 Author: Oleg Broytman <ph...@ph...> Date: Mon Feb 16 19:31:18 2015 +0300 Merge pull request #83 from drnlm/fix_lookupConvertor Change lookupConverter to handle python 3 behaviour http://sourceforge.net/p/sqlobject/sqlobject/ci/eb878a622e05d0c703d5433c2ddf18a4799cb680 commit eb878a622e05d0c703d5433c2ddf18a4799cb680 Author: Neil <drn...@gm...> Date: Mon Feb 16 16:47:35 2015 +0200 Expand upon clarifying comment diff --git a/sqlobject/converters.py b/sqlobject/converters.py index 64983fe..87879f2 100644 --- a/sqlobject/converters.py +++ b/sqlobject/converters.py @@ -65,7 +65,7 @@ class ConverterRegistry: else: def lookupConverter(self, value, default=None): # python 3 doesn't have classic classes, so everything's - # in self.klass + # in self.klass due to comparison order in registerConvertor return self.klass.get(value.__class__, default) converters = ConverterRegistry() http://sourceforge.net/p/sqlobject/sqlobject/ci/4414ff1f2b1d142dfb3115b2f3336e2ebe7b4aa9 commit 4414ff1f2b1d142dfb3115b2f3336e2ebe7b4aa9 Author: Neil <drn...@gm...> Date: Mon Feb 16 16:46:42 2015 +0200 Move version check out of lookupConvertor method diff --git a/sqlobject/converters.py b/sqlobject/converters.py index 045f79c..64983fe 100644 --- a/sqlobject/converters.py +++ b/sqlobject/converters.py @@ -56,13 +56,14 @@ class ConverterRegistry: else: self.basic[typ] = func - def lookupConverter(self, value, default=None): - if sys.version_info[0] < 3: + if sys.version_info[0] < 3: + def lookupConverter(self, value, default=None): if type(value) is InstanceType: # lookup on klasses dict return self.klass.get(value.__class__, default) return self.basic.get(type(value), default) - else: + else: + def lookupConverter(self, value, default=None): # python 3 doesn't have classic classes, so everything's # in self.klass return self.klass.get(value.__class__, default) http://sourceforge.net/p/sqlobject/sqlobject/ci/fbd179e40cd4c293a604b7830a320aa8e1af5bf1 commit fbd179e40cd4c293a604b7830a320aa8e1af5bf1 Author: Neil <drn...@gm...> Date: Wed Feb 11 17:47:22 2015 +0200 Use functools.reduce, for python 3 compatibility diff --git a/sqlobject/inheritance/__init__.py b/sqlobject/inheritance/__init__.py index 8d3cf1e..5795458 100644 --- a/sqlobject/inheritance/__init__.py +++ b/sqlobject/inheritance/__init__.py @@ -1,3 +1,5 @@ +from functools import reduce + from sqlobject import dbconnection from sqlobject import classregistry from sqlobject import events http://sourceforge.net/p/sqlobject/sqlobject/ci/7e955f802a8c426894790df3534130b423ef61ba commit 7e955f802a8c426894790df3534130b423ef61ba Author: Neil <drn...@gm...> Date: Wed Feb 11 17:49:19 2015 +0200 Use next builtin diff --git a/sqlobject/tests/test_basic.py b/sqlobject/tests/test_basic.py index 2e7c775..01878f4 100644 --- a/sqlobject/tests/test_basic.py +++ b/sqlobject/tests/test_basic.py @@ -237,7 +237,7 @@ def testForeignKeyDropTableCascade(): tc6b.destroySelf() assert TestSO5.select().count() == 1 assert TestSO6.select().count() == 0 - assert iter(TestSO5.select()).next() == tc5b + assert next(iter(TestSO5.select())) == tc5b tc6c = TestSO6(name='3') tc5b.other = tc6c assert TestSO5.select().count() == 1 http://sourceforge.net/p/sqlobject/sqlobject/ci/aafa59cac20f6686859e11b85cc14eb0213b44f9 commit aafa59cac20f6686859e11b85cc14eb0213b44f9 Author: Neil <drn...@gm...> Date: Thu Feb 12 17:35:57 2015 +0200 Guard against comparison with None diff --git a/sqlobject/col.py b/sqlobject/col.py index 7c3df4e..8cbf04b 100644 --- a/sqlobject/col.py +++ b/sqlobject/col.py @@ -697,7 +697,7 @@ class SOIntCol(SOCol): if str is None or len(str) < 1: return None - if self.length >= 1: + if self.length and self.length >= 1: _ret = "%s(%d)" % (_ret, self.length) if self.unsigned: _ret = _ret + " UNSIGNED" http://sourceforge.net/p/sqlobject/sqlobject/ci/056fd5398af45742abee0d419c8687d76c443569 commit 056fd5398af45742abee0d419c8687d76c443569 Author: Neil <drn...@gm...> Date: Thu Feb 12 17:59:42 2015 +0200 Use args to get exception details diff --git a/sqlobject/sqlite/sqliteconnection.py b/sqlobject/sqlite/sqliteconnection.py index 1710143..a0c347b 100644 --- a/sqlobject/sqlite/sqliteconnection.py +++ b/sqlobject/sqlite/sqliteconnection.py @@ -18,7 +18,7 @@ sqlite2_Binary = None class ErrorMessage(str): def __new__(cls, e): - obj = str.__new__(cls, e[0]) + obj = str.__new__(cls, e.args[0]) obj.code = None obj.module = e.__module__ obj.exception = e.__class__.__name__ http://sourceforge.net/p/sqlobject/sqlobject/ci/c962c5ea401c74343becc23ad0842c3918ec7414 commit c962c5ea401c74343becc23ad0842c3918ec7414 Author: Neil <drn...@gm...> Date: Thu Feb 12 18:17:12 2015 +0200 Support python 3 iter interface diff --git a/sqlobject/dbconnection.py b/sqlobject/dbconnection.py index 19e14d7..57ca294 100644 --- a/sqlobject/dbconnection.py +++ b/sqlobject/dbconnection.py @@ -750,6 +750,9 @@ class Iteration(object): def __iter__(self): return self + def __next__(self): + return self.next() + def next(self): result = self.cursor.fetchone() if result is None: http://sourceforge.net/p/sqlobject/sqlobject/ci/85cc5fe77c7dc412b2a4ed5bc7dcda51ea37cb97 commit 85cc5fe77c7dc412b2a4ed5bc7dcda51ea37cb97 Author: Neil <drn...@gm...> Date: Thu Feb 12 18:09:57 2015 +0200 Ensure we have a list for slice tests in python 3 diff --git a/sqlobject/tests/test_slice.py b/sqlobject/tests/test_slice.py index c612534..5e756e1 100644 --- a/sqlobject/tests/test_slice.py +++ b/sqlobject/tests/test_slice.py @@ -8,6 +8,11 @@ from sqlobject.tests.dbtest import * ######################################## +def listrange(*args): + """Always return a list, for py3k compatibility""" + return list(range(*args)) + + class Counter(SQLObject): number = IntCol(notNull=True) @@ -27,28 +32,28 @@ class TestSlice: def test_slice(self): self.counterEqual( - Counter.select(None, orderBy='number'), range(100)) + Counter.select(None, orderBy='number'), listrange(100)) self.counterEqual( Counter.select(None, orderBy='number')[10:20], - range(10, 20)) + listrange(10, 20)) self.counterEqual( Counter.select(None, orderBy='number')[20:30][:5], - range(20, 25)) + listrange(20, 25)) self.counterEqual( Counter.select(None, orderBy='number')[20:30][1:5], - range(21, 25)) + listrange(21, 25)) self.counterEqual( Counter.select(None, orderBy='number')[:-10], - range(0, 90)) + listrange(0, 90)) self.counterEqual( Counter.select(None, orderBy='number', reversed=True), - range(99, -1, -1)) + listrange(99, -1, -1)) self.counterEqual( Counter.select(None, orderBy='-number'), - range(99, -1, -1)) + listrange(99, -1, -1)) http://sourceforge.net/p/sqlobject/sqlobject/ci/4513d2e88d0527665f6b49ab66ea30a27e7c2040 commit 4513d2e88d0527665f6b49ab66ea30a27e7c2040 Author: Neil <drn...@gm...> Date: Thu Feb 12 18:09:41 2015 +0200 drop xrange diff --git a/sqlobject/cache.py b/sqlobject/cache.py index 111b5a3..ba6361d 100644 --- a/sqlobject/cache.py +++ b/sqlobject/cache.py @@ -195,7 +195,7 @@ class CacheFactory(object): self.expiredCache.pop(key, None) keys = self.cache.keys() - for i in xrange(self.cullOffset, len(keys), self.cullFraction): + for i in range(self.cullOffset, len(keys), self.cullFraction): id = keys[i] # create a weakref, then remove from the cache obj = ref(self.cache[id]) diff --git a/sqlobject/main.py b/sqlobject/main.py index fabd3b4..ecae515 100644 --- a/sqlobject/main.py +++ b/sqlobject/main.py @@ -1426,7 +1426,7 @@ class SQLObject(with_metaclass(declarative.DeclarativeMeta, object)): cls.__name__, name, repr(value))) else: names = [] - for i in xrange(len(name)): + for i in range(len(name)): names.append("%s = %s" % (name[i], repr(value[i]))) names = ', '.join(names) raise SQLObjectNotFound( http://sourceforge.net/p/sqlobject/sqlobject/ci/9e74a80a3abfa69fffae00bea644f2d5b239be00 commit 9e74a80a3abfa69fffae00bea644f2d5b239be00 Author: Neil <drn...@gm...> Date: Wed Feb 11 17:46:24 2015 +0200 Use codecs.encode for rot13 encoding, to be compatible with python 3 diff --git a/sqlobject/tests/test_basic.py b/sqlobject/tests/test_basic.py index a481708..2e7c775 100644 --- a/sqlobject/tests/test_basic.py +++ b/sqlobject/tests/test_basic.py @@ -1,6 +1,7 @@ import py.test from sqlobject import * from sqlobject.tests.dbtest import * +import codecs class TestSO1(SQLObject): @@ -14,7 +15,7 @@ class TestSO1(SQLObject): cacheValues = False def _set_passwd(self, passwd): - self._SO_set_passwd(passwd.encode('rot13')) + self._SO_set_passwd(codecs.encode(passwd, 'rot13')) def setupGetters(cls): @@ -28,7 +29,7 @@ def test_case1(): setupGetters(TestSO1) bob = TestSO1.selectBy(name='bob')[0] assert bob.name == 'bob' - assert bob.passwd == 'god'.encode('rot13') + assert bob.passwd == codecs.encode('god', 'rot13') bobs = TestSO1.selectBy(name='bob')[:10] assert len(list(bobs)) == 1 @@ -73,14 +74,14 @@ class TestSO2(SQLObject): passwd = StringCol(length=10) def _set_passwd(self, passwd): - self._SO_set_passwd(passwd.encode('rot13')) + self._SO_set_passwd(codecs.encode(passwd, 'rot13')) def test_case2(): setupGetters(TestSO2) bob = TestSO2.selectBy(name='bob')[0] assert bob.name == 'bob' - assert bob.passwd == 'god'.encode('rot13') + assert bob.passwd == codecs.encode('god', 'rot13') class Student(SQLObject): http://sourceforge.net/p/sqlobject/sqlobject/ci/71df75e74879b273fd861afd39e030d618baeb57 commit 71df75e74879b273fd861afd39e030d618baeb57 Author: Neil <drn...@gm...> Date: Fri Feb 13 12:07:57 2015 +0200 python 3 keys don't have a sort method diff --git a/sqlobject/classregistry.py b/sqlobject/classregistry.py index 132afef..07e5abf 100644 --- a/sqlobject/classregistry.py +++ b/sqlobject/classregistry.py @@ -103,8 +103,7 @@ class ClassRegistry(object): try: return self.classes[className] except KeyError: - all = self.classes.keys() - all.sort() + all = sorted(self.classes.keys()) raise KeyError( "No class %s found in the registry %s (these classes " "exist: %s)" diff --git a/sqlobject/inheritance/tests/test_asdict.py b/sqlobject/inheritance/tests/test_asdict.py index 6e37d03..e88ac67 100644 --- a/sqlobject/inheritance/tests/test_asdict.py +++ b/sqlobject/inheritance/tests/test_asdict.py @@ -28,8 +28,7 @@ def test_getColumns(): (InheritablePersonAD, ['firstName', 'lastName']), (ManagerAD, ['department', 'firstName', 'lastName']), (EmployeeAD, ['firstName', 'lastName', 'position'])): - _columns = klass.sqlmeta.getColumns().keys() - _columns.sort() + _columns = sorted(klass.sqlmeta.getColumns().keys()) assert _columns == columns http://sourceforge.net/p/sqlobject/sqlobject/ci/d5612ab75b6556f7f041eb31c2541acf649ff7a4 commit d5612ab75b6556f7f041eb31c2541acf649ff7a4 Author: Neil <drn...@gm...> Date: Thu Feb 12 17:40:01 2015 +0200 Change lookupConverter to handle python 3 behaviour diff --git a/sqlobject/converters.py b/sqlobject/converters.py index 35cfcdc..045f79c 100644 --- a/sqlobject/converters.py +++ b/sqlobject/converters.py @@ -57,10 +57,15 @@ class ConverterRegistry: self.basic[typ] = func def lookupConverter(self, value, default=None): - if type(value) is InstanceType: - # lookup on klasses dict + if sys.version_info[0] < 3: + if type(value) is InstanceType: + # lookup on klasses dict + return self.klass.get(value.__class__, default) + return self.basic.get(type(value), default) + else: + # python 3 doesn't have classic classes, so everything's + # in self.klass return self.klass.get(value.__class__, default) - return self.basic.get(type(value), default) converters = ConverterRegistry() registerConverter = converters.registerConverter ----------------------------------------------------------------------- Summary of changes: sqlobject/cache.py | 2 +- sqlobject/classregistry.py | 3 +-- sqlobject/col.py | 2 +- sqlobject/converters.py | 14 ++++++++++---- sqlobject/dbconnection.py | 3 +++ sqlobject/inheritance/__init__.py | 2 ++ sqlobject/inheritance/tests/test_asdict.py | 3 +-- sqlobject/main.py | 2 +- sqlobject/sqlite/sqliteconnection.py | 2 +- sqlobject/tests/test_basic.py | 11 ++++++----- sqlobject/tests/test_slice.py | 19 ++++++++++++------- 11 files changed, 39 insertions(+), 24 deletions(-) hooks/post-receive -- SQLObject development repository |