sqlobject-cvs Mailing List for SQLObject (Page 50)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(9) |
Apr
(74) |
May
(29) |
Jun
(16) |
Jul
(28) |
Aug
(10) |
Sep
(57) |
Oct
(9) |
Nov
(29) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(7) |
Feb
(14) |
Mar
(6) |
Apr
(3) |
May
(12) |
Jun
(34) |
Jul
(9) |
Aug
(29) |
Sep
(22) |
Oct
(2) |
Nov
(15) |
Dec
(52) |
2005 |
Jan
(47) |
Feb
(78) |
Mar
(14) |
Apr
(35) |
May
(33) |
Jun
(16) |
Jul
(26) |
Aug
(63) |
Sep
(40) |
Oct
(96) |
Nov
(96) |
Dec
(123) |
2006 |
Jan
(159) |
Feb
(144) |
Mar
(64) |
Apr
(31) |
May
(88) |
Jun
(48) |
Jul
(16) |
Aug
(64) |
Sep
(87) |
Oct
(92) |
Nov
(56) |
Dec
(76) |
2007 |
Jan
(94) |
Feb
(103) |
Mar
(126) |
Apr
(123) |
May
(85) |
Jun
(11) |
Jul
(130) |
Aug
(47) |
Sep
(65) |
Oct
(70) |
Nov
(12) |
Dec
(11) |
2008 |
Jan
(30) |
Feb
(55) |
Mar
(88) |
Apr
(20) |
May
(50) |
Jun
|
Jul
(38) |
Aug
(1) |
Sep
(9) |
Oct
(5) |
Nov
(6) |
Dec
(39) |
2009 |
Jan
(8) |
Feb
(16) |
Mar
(3) |
Apr
(33) |
May
(44) |
Jun
(1) |
Jul
(10) |
Aug
(33) |
Sep
(74) |
Oct
(22) |
Nov
|
Dec
(15) |
2010 |
Jan
(28) |
Feb
(22) |
Mar
(46) |
Apr
(29) |
May
(1) |
Jun
(1) |
Jul
(27) |
Aug
(8) |
Sep
(5) |
Oct
(33) |
Nov
(24) |
Dec
(41) |
2011 |
Jan
(4) |
Feb
(12) |
Mar
(35) |
Apr
(29) |
May
(19) |
Jun
(16) |
Jul
(32) |
Aug
(25) |
Sep
(5) |
Oct
(11) |
Nov
(21) |
Dec
(12) |
2012 |
Jan
(3) |
Feb
(4) |
Mar
(20) |
Apr
(4) |
May
(25) |
Jun
(13) |
Jul
|
Aug
|
Sep
(2) |
Oct
(25) |
Nov
(9) |
Dec
(1) |
2013 |
Jan
(6) |
Feb
(8) |
Mar
|
Apr
(10) |
May
(31) |
Jun
(7) |
Jul
(18) |
Aug
(33) |
Sep
(4) |
Oct
(16) |
Nov
|
Dec
(27) |
2014 |
Jan
(2) |
Feb
|
Mar
|
Apr
(11) |
May
(39) |
Jun
(8) |
Jul
(11) |
Aug
(4) |
Sep
|
Oct
(27) |
Nov
|
Dec
(71) |
2015 |
Jan
(17) |
Feb
(47) |
Mar
(33) |
Apr
|
May
|
Jun
(9) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
2016 |
Jan
(4) |
Feb
(4) |
Mar
|
Apr
|
May
(12) |
Jun
(7) |
Jul
(9) |
Aug
(31) |
Sep
(8) |
Oct
(3) |
Nov
(15) |
Dec
(1) |
2017 |
Jan
(13) |
Feb
(7) |
Mar
(14) |
Apr
(8) |
May
(10) |
Jun
(4) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(4) |
Dec
(5) |
2018 |
Jan
(2) |
Feb
(8) |
Mar
|
Apr
(4) |
May
|
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
2019 |
Jan
(1) |
Feb
(16) |
Mar
(1) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
(3) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
2021 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(1) |
Nov
(1) |
Dec
(4) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(3) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
|
2024 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(9) |
2025 |
Jan
|
Feb
(4) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sub...@co...> - 2010-02-26 21:25:32
|
Author: phd Date: 2010-02-26 14:25:26 -0700 (Fri, 26 Feb 2010) New Revision: 4108 Modified: SQLObject/branches/0.11/sqlobject/main.py Log: Fixed a comment. Modified: SQLObject/branches/0.11/sqlobject/main.py =================================================================== --- SQLObject/branches/0.11/sqlobject/main.py 2010-02-26 21:22:50 UTC (rev 4107) +++ SQLObject/branches/0.11/sqlobject/main.py 2010-02-26 21:25:26 UTC (rev 4108) @@ -768,7 +768,7 @@ # Do not check hasattr(cls, '_connection') here - it is possible # SQLObject parent class has a connection attribute that came - # from sqlhub, e.g.; # check __dict__ only. + # from sqlhub, e.g.; check __dict__ only. if connection and ('_connection' not in cls.__dict__): cls.setConnection(connection) |
From: <sub...@co...> - 2010-02-26 21:23:00
|
Author: phd Date: 2010-02-26 14:22:50 -0700 (Fri, 26 Feb 2010) New Revision: 4107 Modified: SQLObject/branches/0.11/docs/News.txt SQLObject/branches/0.11/sqlobject/main.py SQLObject/branches/0.11/sqlobject/tests/test_select.py Log: Do not set _perConnection flag if get() or _init() is passed the same connection; this is often the case with select(). Modified: SQLObject/branches/0.11/docs/News.txt =================================================================== --- SQLObject/branches/0.11/docs/News.txt 2010-02-10 15:49:07 UTC (rev 4106) +++ SQLObject/branches/0.11/docs/News.txt 2010-02-26 21:22:50 UTC (rev 4107) @@ -14,6 +14,9 @@ connection is not a transaction and is in autocommit mode - remove parent row(s). +* Do not set _perConnection flag if get() or _init() is passed the same + connection; this is often the case with select(). + SQLObject 0.11.3 ================ Modified: SQLObject/branches/0.11/sqlobject/main.py =================================================================== --- SQLObject/branches/0.11/sqlobject/main.py 2010-02-10 15:49:07 UTC (rev 4106) +++ SQLObject/branches/0.11/sqlobject/main.py 2010-02-26 21:22:50 UTC (rev 4107) @@ -922,7 +922,7 @@ # If no connection was given, we'll inherit the class # instance variable which should have a _connection # attribute. - if connection is not None: + if (connection is not None) and (self._connection != connection): self._connection = connection # Sometimes we need to know if this instance is # global or tied to a particular connection. @@ -1208,9 +1208,10 @@ # Pass the connection object along if we were given one. if kw.has_key('connection'): - self._connection = kw['connection'] - self.sqlmeta._perConnection = True - del kw['connection'] + connection = kw.pop('connection') + if self._connection != connection: + self._connection = connection + self.sqlmeta._perConnection = True self._SO_writeLock = threading.Lock() Modified: SQLObject/branches/0.11/sqlobject/tests/test_select.py =================================================================== --- SQLObject/branches/0.11/sqlobject/tests/test_select.py 2010-02-10 15:49:07 UTC (rev 4106) +++ SQLObject/branches/0.11/sqlobject/tests/test_select.py 2010-02-26 21:22:50 UTC (rev 4107) @@ -180,3 +180,8 @@ setupClass(IterTest) IterTest(name='sqlobject') IterTest.select(IterTest.q.name==u'sqlobject') + +def test_select_perConnection(): + setupClass(IterTest) + IterTest(name='a') + assert not IterTest.select().getOne().sqlmeta._perConnection |
From: SourceForge.net <no...@so...> - 2010-02-18 04:48:00
|
Patches item #2954013, was opened at 2010-02-17 22:48 Message generated for change (Tracker Item Submitted) made by dvkeeney You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2954013&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: dkeeney (dvkeeney) Assigned to: Nobody/Anonymous (nobody) Summary: Rdbhost connection module Initial Comment: Revised rdbconnection.py to simplify setting of database encoding. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=2954013&group_id=74338 |
From: <sub...@co...> - 2010-02-10 15:49:13
|
Author: phd Date: 2010-02-10 08:49:07 -0700 (Wed, 10 Feb 2010) New Revision: 4106 Modified: SQLObject/trunk/sqlobject/tests/test_picklecol.py Log: Merged a patch from revision 4104 from branch 0.11: PickleCol requires blobData. Modified: SQLObject/trunk/sqlobject/tests/test_picklecol.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_picklecol.py 2010-02-10 15:48:43 UTC (rev 4105) +++ SQLObject/trunk/sqlobject/tests/test_picklecol.py 2010-02-10 15:49:07 UTC (rev 4106) @@ -15,6 +15,8 @@ pickledata = PickleCol(default=None, length=65535) def test_pickleCol(): + if not supports('blobData'): + return setupClass([PickleContainer], force=True) mypickledata = PickleData() @@ -33,4 +35,3 @@ assert s2.pi == mypickledata.pi assert s2.question == mypickledata.question assert s2.answer == mypickledata.answer - |
From: <sub...@co...> - 2010-02-10 15:48:52
|
Author: phd Date: 2010-02-10 08:48:43 -0700 (Wed, 10 Feb 2010) New Revision: 4105 Modified: SQLObject/branches/0.12/sqlobject/tests/test_picklecol.py Log: Merged a patch from revision 4104 from branch 0.11: PickleCol requires blobData. Modified: SQLObject/branches/0.12/sqlobject/tests/test_picklecol.py =================================================================== --- SQLObject/branches/0.12/sqlobject/tests/test_picklecol.py 2010-02-10 15:47:25 UTC (rev 4104) +++ SQLObject/branches/0.12/sqlobject/tests/test_picklecol.py 2010-02-10 15:48:43 UTC (rev 4105) @@ -15,6 +15,8 @@ pickledata = PickleCol(default=None, length=65535) def test_pickleCol(): + if not supports('blobData'): + return setupClass([PickleContainer], force=True) mypickledata = PickleData() @@ -33,4 +35,3 @@ assert s2.pi == mypickledata.pi assert s2.question == mypickledata.question assert s2.answer == mypickledata.answer - |
From: <sub...@co...> - 2010-02-10 15:47:32
|
Author: phd Date: 2010-02-10 08:47:25 -0700 (Wed, 10 Feb 2010) New Revision: 4104 Modified: SQLObject/branches/0.11/sqlobject/tests/test_picklecol.py Log: PickleCol requires blobData. Modified: SQLObject/branches/0.11/sqlobject/tests/test_picklecol.py =================================================================== --- SQLObject/branches/0.11/sqlobject/tests/test_picklecol.py 2010-02-08 18:12:07 UTC (rev 4103) +++ SQLObject/branches/0.11/sqlobject/tests/test_picklecol.py 2010-02-10 15:47:25 UTC (rev 4104) @@ -15,6 +15,8 @@ pickledata = PickleCol(default=None, length=65535) def test_pickleCol(): + if not supports('blobData'): + return setupClass([PickleContainer], force=True) mypickledata = PickleData() @@ -33,4 +35,3 @@ assert s2.pi == mypickledata.pi assert s2.question == mypickledata.question assert s2.answer == mypickledata.answer - |
From: SourceForge.net <no...@so...> - 2010-02-10 15:28:07
|
Bugs item #1547004, was opened at 2006-08-26 08:05 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1547004&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: DBM Group: SQLObject from repository >Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: elpargo (elpargo) Assigned to: Nobody/Anonymous (nobody) Summary: SQLObject does not reconnect Initial Comment: this is from the 0.7bug fix branch a lot of background has been created on this in Turbogears bug tracker. mainly in http://trac.turbogears.org/turbogears/ticket/872 http://trac.turbogears.org/turbogears/ticket/781 Basically the connection after being idle is drop and SO engine is not aware of this. Many patches have been proposed but none accepted. ---------------------------------------------------------------------- Comment By: Oleg Broytman (phd) Date: 2007-03-06 18:23 Message: Logged In: YES user_id=4799 Originator: NO Partially fixed: in the revisions 2396-2399 there were patches that allows autoreconnect for MySQLdb 1.2.2+. ---------------------------------------------------------------------- Comment By: sophana (sophana) Date: 2006-12-10 23:56 Message: Logged In: YES user_id=931678 Originator: NO I think the best solution is the one included in this mysqldb patch. The reconnection is handled directly in the mysql C api with an option. The problem Is that this option is only available from mysql 5.0.x http://sourceforge.net/tracker/index.php?func=detail&aid=1483074&group_id=22307&atid=374934 Other problem this patch is for mysqldb 1.2.1p2 which has problems with unicode. Have to see if the patch is already applied or applicable to 1.2.2 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1547004&group_id=74338 |
From: <sub...@co...> - 2010-02-08 18:38:08
|
Author: phd Date: 2010-02-08 11:12:07 -0700 (Mon, 08 Feb 2010) New Revision: 4103 Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/inheritance/__init__.py SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py Log: Merged a bugfix in inheritance from revision 4102 from branch 0.12. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2010-02-08 18:10:24 UTC (rev 4102) +++ SQLObject/trunk/docs/News.txt 2010-02-08 18:12:07 UTC (rev 4103) @@ -26,6 +26,11 @@ the case of inherited idName inherited value takes precedence; to allow Style to set idName reset inherited idName to None. +SQLObject 0.12.2 +================ + +* A bugfix ported from `SQLObject 0.11.4`_. + SQLObject 0.12.1 ================ @@ -85,6 +90,13 @@ * Removed the last remained string exceptions. +SQLObject 0.11.4 +================ + +* Fixed a bug in inheritance - if creation of the row failed and if the + connection is not a transaction and is in autocommit mode - remove + parent row(s). + SQLObject 0.11.3 ================ Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py =================================================================== --- SQLObject/trunk/sqlobject/inheritance/__init__.py 2010-02-08 18:10:24 UTC (rev 4102) +++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2010-02-08 18:12:07 UTC (rev 4103) @@ -1,9 +1,10 @@ +from sqlobject import dbconnection +from sqlobject import classregistry +from sqlobject import events from sqlobject import sqlbuilder -from sqlobject import classregistry from sqlobject.col import StringCol, ForeignKey from sqlobject.main import sqlmeta, SQLObject, SelectResults, \ makeProperties, unmakeProperties, getterName, setterName -from sqlobject import events import iteration def tablesUsedSet(obj, db): @@ -109,7 +110,7 @@ def setfunc(self, val): if not self.sqlmeta._creating and not getattr(self.sqlmeta, "row_update_sig_suppress", False): self.sqlmeta.send(events.RowUpdateSignal, self, {cname : val}) - + result = setattr(self._parent, cname, val) return setfunc @@ -384,7 +385,20 @@ id = self._parent.id - super(InheritableSQLObject, self)._create(id, **kw) + # TC: Create this record and catch all exceptions in order to destroy + # TC: the parent if the child can not be created. + try: + super(InheritableSQLObject, self)._create(id, **kw) + except: + # If we are outside a transaction and this is a child, destroy the parent + connection = self._connection + if (not isinstance(connection, dbconnection.Transaction) and + connection.autoCommit) and self.sqlmeta.parentClass: + self._parent.destroySelf() + #TC: Do we need to do this?? + self._parent = None + # TC: Reraise the original exception + raise def _findAlternateID(cls, name, dbName, value, connection=None): result = list(cls.selectBy(connection, **{name: value})) Modified: SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py =================================================================== --- SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py 2010-02-08 18:10:24 UTC (rev 4102) +++ SQLObject/trunk/sqlobject/inheritance/tests/test_deep_inheritance.py 2010-02-08 18:12:07 UTC (rev 4103) @@ -13,27 +13,54 @@ manager = ForeignKey("DIManager", default=None) class DIEmployee(DIPerson): - position = StringCol() + position = StringCol(unique=True) class DIManager(DIEmployee): subdudes = MultipleJoin("DIPerson", joinColumn="manager_id") def test_creation_fail(): """ - Try to creae an Manager without specifying a position. - this should fail without leaving any partial records in + Try to create a Manager without specifying a position. + This should fail without leaving any partial records in the database. """ setupClass([DIManager, DIEmployee, DIPerson]) - kwargs ={'firstName':'John', 'lastname':'Doe'} + kwargs ={'firstName': 'John', 'lastname': 'Doe'} raises(TypeError, DIManager, **kwargs) - #what we really need to check for is partial records in the database. - #the following is not really adaquate. persons = DIEmployee.select(DIPerson.q.firstName == 'John') assert persons.count() == 0 +def test_creation_fail2(): + """ + Try to create two Managers with the same position. + This should fail without leaving any partial records in + the database. + + """ + setupClass([DIManager, DIEmployee, DIPerson]) + + kwargs ={'firstName': 'John', 'lastName': 'Doe', 'position': 'Project Manager'} + DIManager(**kwargs) + persons = DIEmployee.select(DIPerson.q.firstName == 'John') + assert persons.count() == 1 + + kwargs ={'firstName': 'John', 'lastName': 'Doe II', 'position': 'Project Manager'} + raises(Exception, DIManager, **kwargs) + persons = DIPerson.select(DIPerson.q.firstName == 'John') + assert persons.count() == 1 + + if not supports('transactions'): + return + transaction = DIPerson._connection.transaction() + kwargs ={'firstName': 'John', 'lastName': 'Doe III', 'position': 'Project Manager'} + raises(Exception, DIManager, connection=transaction, **kwargs) + transaction.rollback() + transaction.begin() + persons = DIPerson.select(DIPerson.q.firstName == 'John', connection=transaction) + assert persons.count() == 1 + def test_deep_inheritance(): setupClass([DIManager, DIEmployee, DIPerson]) |
From: <sub...@co...> - 2010-02-08 18:10:31
|
Author: phd Date: 2010-02-08 11:10:24 -0700 (Mon, 08 Feb 2010) New Revision: 4102 Modified: SQLObject/branches/0.12/docs/News.txt SQLObject/branches/0.12/sqlobject/inheritance/__init__.py SQLObject/branches/0.12/sqlobject/inheritance/tests/test_deep_inheritance.py Log: Merged a bugfix in inheritance from revision 4101 from branch 0.11. Modified: SQLObject/branches/0.12/docs/News.txt =================================================================== --- SQLObject/branches/0.12/docs/News.txt 2010-02-08 18:06:17 UTC (rev 4101) +++ SQLObject/branches/0.12/docs/News.txt 2010-02-08 18:10:24 UTC (rev 4102) @@ -7,6 +7,11 @@ .. _start: +SQLObject 0.12.2 +================ + +* A bugfix ported from `SQLObject 0.11.4`_. + SQLObject 0.12.1 ================ @@ -66,6 +71,13 @@ * Removed the last remained string exceptions. +SQLObject 0.11.4 +================ + +* Fixed a bug in inheritance - if creation of the row failed and if the + connection is not a transaction and is in autocommit mode - remove + parent row(s). + SQLObject 0.11.3 ================ Modified: SQLObject/branches/0.12/sqlobject/inheritance/__init__.py =================================================================== --- SQLObject/branches/0.12/sqlobject/inheritance/__init__.py 2010-02-08 18:06:17 UTC (rev 4101) +++ SQLObject/branches/0.12/sqlobject/inheritance/__init__.py 2010-02-08 18:10:24 UTC (rev 4102) @@ -1,9 +1,10 @@ +from sqlobject import dbconnection +from sqlobject import classregistry +from sqlobject import events from sqlobject import sqlbuilder -from sqlobject import classregistry from sqlobject.col import StringCol, ForeignKey from sqlobject.main import sqlmeta, SQLObject, SelectResults, \ makeProperties, unmakeProperties, getterName, setterName -from sqlobject import events import iteration def tablesUsedSet(obj, db): @@ -109,7 +110,7 @@ def setfunc(self, val): if not self.sqlmeta._creating and not getattr(self.sqlmeta, "row_update_sig_suppress", False): self.sqlmeta.send(events.RowUpdateSignal, self, {cname : val}) - + result = setattr(self._parent, cname, val) return setfunc @@ -384,7 +385,20 @@ id = self._parent.id - super(InheritableSQLObject, self)._create(id, **kw) + # TC: Create this record and catch all exceptions in order to destroy + # TC: the parent if the child can not be created. + try: + super(InheritableSQLObject, self)._create(id, **kw) + except: + # If we are outside a transaction and this is a child, destroy the parent + connection = self._connection + if (not isinstance(connection, dbconnection.Transaction) and + connection.autoCommit) and self.sqlmeta.parentClass: + self._parent.destroySelf() + #TC: Do we need to do this?? + self._parent = None + # TC: Reraise the original exception + raise def _findAlternateID(cls, name, dbName, value, connection=None): result = list(cls.selectBy(connection, **{name: value})) Modified: SQLObject/branches/0.12/sqlobject/inheritance/tests/test_deep_inheritance.py =================================================================== --- SQLObject/branches/0.12/sqlobject/inheritance/tests/test_deep_inheritance.py 2010-02-08 18:06:17 UTC (rev 4101) +++ SQLObject/branches/0.12/sqlobject/inheritance/tests/test_deep_inheritance.py 2010-02-08 18:10:24 UTC (rev 4102) @@ -13,27 +13,54 @@ manager = ForeignKey("DIManager", default=None) class DIEmployee(DIPerson): - position = StringCol() + position = StringCol(unique=True) class DIManager(DIEmployee): subdudes = MultipleJoin("DIPerson", joinColumn="manager_id") def test_creation_fail(): """ - Try to creae an Manager without specifying a position. - this should fail without leaving any partial records in + Try to create a Manager without specifying a position. + This should fail without leaving any partial records in the database. """ setupClass([DIManager, DIEmployee, DIPerson]) - kwargs ={'firstName':'John', 'lastname':'Doe'} + kwargs ={'firstName': 'John', 'lastname': 'Doe'} raises(TypeError, DIManager, **kwargs) - #what we really need to check for is partial records in the database. - #the following is not really adaquate. persons = DIEmployee.select(DIPerson.q.firstName == 'John') assert persons.count() == 0 +def test_creation_fail2(): + """ + Try to create two Managers with the same position. + This should fail without leaving any partial records in + the database. + + """ + setupClass([DIManager, DIEmployee, DIPerson]) + + kwargs ={'firstName': 'John', 'lastName': 'Doe', 'position': 'Project Manager'} + DIManager(**kwargs) + persons = DIEmployee.select(DIPerson.q.firstName == 'John') + assert persons.count() == 1 + + kwargs ={'firstName': 'John', 'lastName': 'Doe II', 'position': 'Project Manager'} + raises(Exception, DIManager, **kwargs) + persons = DIPerson.select(DIPerson.q.firstName == 'John') + assert persons.count() == 1 + + if not supports('transactions'): + return + transaction = DIPerson._connection.transaction() + kwargs ={'firstName': 'John', 'lastName': 'Doe III', 'position': 'Project Manager'} + raises(Exception, DIManager, connection=transaction, **kwargs) + transaction.rollback() + transaction.begin() + persons = DIPerson.select(DIPerson.q.firstName == 'John', connection=transaction) + assert persons.count() == 1 + def test_deep_inheritance(): setupClass([DIManager, DIEmployee, DIPerson]) |
From: <sub...@co...> - 2010-02-08 18:06:25
|
Author: phd Date: 2010-02-08 11:06:17 -0700 (Mon, 08 Feb 2010) New Revision: 4101 Modified: SQLObject/branches/0.11/docs/News.txt SQLObject/branches/0.11/sqlobject/inheritance/__init__.py SQLObject/branches/0.11/sqlobject/inheritance/tests/test_deep_inheritance.py Log: Fixed a bug in inheritance. Modified: SQLObject/branches/0.11/docs/News.txt =================================================================== --- SQLObject/branches/0.11/docs/News.txt 2010-02-05 13:51:02 UTC (rev 4100) +++ SQLObject/branches/0.11/docs/News.txt 2010-02-08 18:06:17 UTC (rev 4101) @@ -7,6 +7,13 @@ .. _start: +SQLObject 0.11.4 +================ + +* Fixed a bug in inheritance - if creation of the row failed and if the + connection is not a transaction and is in autocommit mode - remove + parent row(s). + SQLObject 0.11.3 ================ Modified: SQLObject/branches/0.11/sqlobject/inheritance/__init__.py =================================================================== --- SQLObject/branches/0.11/sqlobject/inheritance/__init__.py 2010-02-05 13:51:02 UTC (rev 4100) +++ SQLObject/branches/0.11/sqlobject/inheritance/__init__.py 2010-02-08 18:06:17 UTC (rev 4101) @@ -1,9 +1,10 @@ +from sqlobject import dbconnection +from sqlobject import classregistry +from sqlobject import events from sqlobject import sqlbuilder -from sqlobject import classregistry from sqlobject.col import StringCol, ForeignKey from sqlobject.main import sqlmeta, SQLObject, SelectResults, \ makeProperties, unmakeProperties, getterName, setterName -from sqlobject import events import iteration def tablesUsedSet(obj, db): @@ -109,7 +110,7 @@ def setfunc(self, val): if not self.sqlmeta._creating and not getattr(self.sqlmeta, "row_update_sig_suppress", False): self.sqlmeta.send(events.RowUpdateSignal, self, {cname : val}) - + result = setattr(self._parent, cname, val) return setfunc @@ -384,7 +385,20 @@ id = self._parent.id - super(InheritableSQLObject, self)._create(id, **kw) + # TC: Create this record and catch all exceptions in order to destroy + # TC: the parent if the child can not be created. + try: + super(InheritableSQLObject, self)._create(id, **kw) + except: + # If we are outside a transaction and this is a child, destroy the parent + connection = self._connection + if (not isinstance(connection, dbconnection.Transaction) and + connection.autoCommit) and self.sqlmeta.parentClass: + self._parent.destroySelf() + #TC: Do we need to do this?? + self._parent = None + # TC: Reraise the original exception + raise def _findAlternateID(cls, name, dbName, value, connection=None): result = list(cls.selectBy(connection, **{name: value})) Modified: SQLObject/branches/0.11/sqlobject/inheritance/tests/test_deep_inheritance.py =================================================================== --- SQLObject/branches/0.11/sqlobject/inheritance/tests/test_deep_inheritance.py 2010-02-05 13:51:02 UTC (rev 4100) +++ SQLObject/branches/0.11/sqlobject/inheritance/tests/test_deep_inheritance.py 2010-02-08 18:06:17 UTC (rev 4101) @@ -13,27 +13,54 @@ manager = ForeignKey("DIManager", default=None) class DIEmployee(DIPerson): - position = StringCol() + position = StringCol(unique=True) class DIManager(DIEmployee): subdudes = MultipleJoin("DIPerson", joinColumn="manager_id") def test_creation_fail(): """ - Try to creae an Manager without specifying a position. - this should fail without leaving any partial records in + Try to create a Manager without specifying a position. + This should fail without leaving any partial records in the database. """ setupClass([DIManager, DIEmployee, DIPerson]) - kwargs ={'firstName':'John', 'lastname':'Doe'} + kwargs ={'firstName': 'John', 'lastname': 'Doe'} raises(TypeError, DIManager, **kwargs) - #what we really need to check for is partial records in the database. - #the following is not really adaquate. persons = DIEmployee.select(DIPerson.q.firstName == 'John') assert persons.count() == 0 +def test_creation_fail2(): + """ + Try to create two Managers with the same position. + This should fail without leaving any partial records in + the database. + + """ + setupClass([DIManager, DIEmployee, DIPerson]) + + kwargs ={'firstName': 'John', 'lastName': 'Doe', 'position': 'Project Manager'} + DIManager(**kwargs) + persons = DIEmployee.select(DIPerson.q.firstName == 'John') + assert persons.count() == 1 + + kwargs ={'firstName': 'John', 'lastName': 'Doe II', 'position': 'Project Manager'} + raises(Exception, DIManager, **kwargs) + persons = DIPerson.select(DIPerson.q.firstName == 'John') + assert persons.count() == 1 + + if not supports('transactions'): + return + transaction = DIPerson._connection.transaction() + kwargs ={'firstName': 'John', 'lastName': 'Doe III', 'position': 'Project Manager'} + raises(Exception, DIManager, connection=transaction, **kwargs) + transaction.rollback() + transaction.begin() + persons = DIPerson.select(DIPerson.q.firstName == 'John', connection=transaction) + assert persons.count() == 1 + def test_deep_inheritance(): setupClass([DIManager, DIEmployee, DIPerson]) |
From: <sub...@co...> - 2010-02-05 14:08:09
|
Author: phd Date: 2010-02-05 06:31:14 -0700 (Fri, 05 Feb 2010) New Revision: 4098 Modified: SQLObject/trunk/sqlobject/main.py Log: Merged revision 4096 from branch 0.11: a comment for the group of rich comparison methods. Modified: SQLObject/trunk/sqlobject/main.py =================================================================== --- SQLObject/trunk/sqlobject/main.py 2010-02-05 13:30:35 UTC (rev 4097) +++ SQLObject/trunk/sqlobject/main.py 2010-02-05 13:31:14 UTC (rev 4098) @@ -1650,6 +1650,9 @@ def tablesUsedImmediate(self): return [self.__class__.q] + + # Comparison + def __eq__(self, other): if self.__class__ is other.__class__: if self.id == other.id: |
From: <sub...@co...> - 2010-02-05 14:08:08
|
Author: phd Date: 2010-02-05 06:43:30 -0700 (Fri, 05 Feb 2010) New Revision: 4099 Added: SQLObject/trunk/sqlobject/tests/test_pickle.py Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/main.py Log: SQLObject instances that don't have a per-instance connection can be pickled and unpickled. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2010-02-05 13:31:14 UTC (rev 4098) +++ SQLObject/trunk/docs/News.txt 2010-02-05 13:43:30 UTC (rev 4099) @@ -13,6 +13,9 @@ Features & Interface -------------------- +* SQLObject instances that don't have a per-instance connection can be + pickled and unpickled. + * Added TimedeltaCol; currently it's only implemented on PostgreSQL as an INTERVAL type. Modified: SQLObject/trunk/sqlobject/main.py =================================================================== --- SQLObject/trunk/sqlobject/main.py 2010-02-05 13:31:14 UTC (rev 4098) +++ SQLObject/trunk/sqlobject/main.py 2010-02-05 13:43:30 UTC (rev 4099) @@ -1675,6 +1675,22 @@ return NotImplemented + def __getstate__(self): + if self.sqlmeta._perConnection: + from pickle import PicklingError + raise PicklingError('Cannot pickle an SQLObject instance that has a per-instance connection') + d = self.__dict__.copy() + del d['sqlmeta'] + del d['_SO_writeLock'] + return d + + def __setstate__(self, d): + self.__init__(_SO_fetch_no_create=1) + self._SO_writeLock = threading.Lock() + self.__dict__.update(d) + self.__class__._connection.cache.put(self.id, self.__class__, self) + + def capitalize(name): return name[0].capitalize() + name[1:] Added: SQLObject/trunk/sqlobject/tests/test_pickle.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_pickle.py (rev 0) +++ SQLObject/trunk/sqlobject/tests/test_pickle.py 2010-02-05 13:43:30 UTC (rev 4099) @@ -0,0 +1,24 @@ +import pickle +from sqlobject import * +from sqlobject.tests.dbtest import * + +######################################## +## Pickle instances +######################################## + +class TestPickle(SQLObject): + question = StringCol() + answer = IntCol() + +test_question = 'The Ulimate Question of Life, the Universe and Everything' +test_answer = 42 + +def test_pickleCol(): + setupClass(TestPickle) + test = TestPickle(question=test_question, answer=test_answer) + + pickle_data = pickle.dumps(test, pickle.HIGHEST_PROTOCOL) + test = pickle.loads(pickle_data) + + assert test.question == test_question + assert test.answer == test_answer |
From: <sub...@co...> - 2010-02-05 14:08:08
|
Author: phd Date: 2010-02-05 06:30:35 -0700 (Fri, 05 Feb 2010) New Revision: 4097 Modified: SQLObject/branches/0.12/sqlobject/main.py Log: Merged revision 4096 from branch 0.11: a comment for the group of rich comparison methods. Modified: SQLObject/branches/0.12/sqlobject/main.py =================================================================== --- SQLObject/branches/0.12/sqlobject/main.py 2010-02-05 13:29:15 UTC (rev 4096) +++ SQLObject/branches/0.12/sqlobject/main.py 2010-02-05 13:30:35 UTC (rev 4097) @@ -1649,6 +1649,9 @@ def tablesUsedImmediate(self): return [self.__class__.q] + + # Comparison + def __eq__(self, other): if self.__class__ is other.__class__: if self.id == other.id: |
From: <sub...@co...> - 2010-02-05 14:08:07
|
Author: phd Date: 2010-02-05 06:51:02 -0700 (Fri, 05 Feb 2010) New Revision: 4100 Modified: SQLObject/trunk/sqlobject/tests/test_pickle.py Log: Instances with per-instance connections aren't pickleable. Modified: SQLObject/trunk/sqlobject/tests/test_pickle.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_pickle.py 2010-02-05 13:43:30 UTC (rev 4099) +++ SQLObject/trunk/sqlobject/tests/test_pickle.py 2010-02-05 13:51:02 UTC (rev 4100) @@ -22,3 +22,7 @@ assert test.question == test_question assert test.answer == test_answer + + TestPickle._connection.cache.clear() + test = TestPickle.get(test.id, connection=TestPickle._connection) + raises(pickle.PicklingError, pickle.dumps, test, pickle.HIGHEST_PROTOCOL) |
From: <sub...@co...> - 2010-02-05 13:29:24
|
Author: phd Date: 2010-02-05 06:29:15 -0700 (Fri, 05 Feb 2010) New Revision: 4096 Modified: SQLObject/branches/0.11/sqlobject/main.py Log: Added a comment for the group of rich comparison methods. Modified: SQLObject/branches/0.11/sqlobject/main.py =================================================================== --- SQLObject/branches/0.11/sqlobject/main.py 2010-02-03 22:27:42 UTC (rev 4095) +++ SQLObject/branches/0.11/sqlobject/main.py 2010-02-05 13:29:15 UTC (rev 4096) @@ -1654,6 +1654,9 @@ def tablesUsedImmediate(self): return [self.__class__.q] + + # Comparison + def __eq__(self, other): if self.__class__ is other.__class__: if self.id == other.id: |
From: <sub...@co...> - 2010-02-01 14:52:55
|
Author: phd Date: 2010-02-01 07:52:49 -0700 (Mon, 01 Feb 2010) New Revision: 4094 Modified: SQLObject/trunk/docs/News.txt Log: Fixed misspellings. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2010-02-01 14:50:22 UTC (rev 4093) +++ SQLObject/trunk/docs/News.txt 2010-02-01 14:52:49 UTC (rev 4094) @@ -20,8 +20,8 @@ -------------- * Do not pollute the base sqlmeta class to allow Style to set idName. In - the case of inherited idName inherited value takes precedence; To allow - Style to set idName resets inherited idName to None. + the case of inherited idName inherited value takes precedence; to allow + Style to set idName reset inherited idName to None. SQLObject 0.12.1 ================ |
From: <sub...@co...> - 2010-02-01 14:50:30
|
Author: phd Date: 2010-02-01 07:50:22 -0700 (Mon, 01 Feb 2010) New Revision: 4093 Modified: SQLObject/trunk/docs/Inheritance.txt Log: Merged misspelling fixes from revision 4091 from branch 0.11. Modified: SQLObject/trunk/docs/Inheritance.txt =================================================================== --- SQLObject/trunk/docs/Inheritance.txt 2010-02-01 14:49:34 UTC (rev 4092) +++ SQLObject/trunk/docs/Inheritance.txt 2010-02-01 14:50:22 UTC (rev 4093) @@ -298,12 +298,12 @@ and override many methods - _SO_setValue(), sync(), syncUpdate() at least. Patches will be gladly accepted. * You'd better restrain yourself to simple use cases. The inheritance - implementation is easiliy choked on more complex cases. + implementation is easily choked on more complex cases. * A join between tables inherited from the same parent produces incorrect result due to joins to the same parent table (they must use different aliases). * Inheritance works in two stages - first it draws the IDs from the parent - table and then it drwas the rows from the children tables. The first + table and then it draws the rows from the children tables. The first stage could fail if you try to do complex things. For example, Children.select(orderBy=Children.q.column, distinct=True) could fail because at the first stage inheritance generates a SELECT |
From: <sub...@co...> - 2010-02-01 14:49:47
|
Author: phd Date: 2010-02-01 07:49:34 -0700 (Mon, 01 Feb 2010) New Revision: 4092 Modified: SQLObject/branches/0.12/docs/Inheritance.txt Log: Merged misspelling fixes from revision 4091 from branch 0.11. Modified: SQLObject/branches/0.12/docs/Inheritance.txt =================================================================== --- SQLObject/branches/0.12/docs/Inheritance.txt 2010-02-01 14:48:16 UTC (rev 4091) +++ SQLObject/branches/0.12/docs/Inheritance.txt 2010-02-01 14:49:34 UTC (rev 4092) @@ -298,12 +298,12 @@ and override many methods - _SO_setValue(), sync(), syncUpdate() at least. Patches will be gladly accepted. * You'd better restrain yourself to simple use cases. The inheritance - implementation is easiliy choked on more complex cases. + implementation is easily choked on more complex cases. * A join between tables inherited from the same parent produces incorrect result due to joins to the same parent table (they must use different aliases). * Inheritance works in two stages - first it draws the IDs from the parent - table and then it drwas the rows from the children tables. The first + table and then it draws the rows from the children tables. The first stage could fail if you try to do complex things. For example, Children.select(orderBy=Children.q.column, distinct=True) could fail because at the first stage inheritance generates a SELECT |
From: <sub...@co...> - 2010-02-01 14:48:23
|
Author: phd Date: 2010-02-01 07:48:16 -0700 (Mon, 01 Feb 2010) New Revision: 4091 Modified: SQLObject/branches/0.11/docs/Inheritance.txt Log: Fixed misspellings. Modified: SQLObject/branches/0.11/docs/Inheritance.txt =================================================================== --- SQLObject/branches/0.11/docs/Inheritance.txt 2010-02-01 14:45:04 UTC (rev 4090) +++ SQLObject/branches/0.11/docs/Inheritance.txt 2010-02-01 14:48:16 UTC (rev 4091) @@ -298,12 +298,12 @@ and override many methods - _SO_setValue(), sync(), syncUpdate() at least. Patches will be gladly accepted. * You'd better restrain yourself to simple use cases. The inheritance - implementation is easiliy choked on more complex cases. + implementation is easily choked on more complex cases. * A join between tables inherited from the same parent produces incorrect result due to joins to the same parent table (they must use different aliases). * Inheritance works in two stages - first it draws the IDs from the parent - table and then it drwas the rows from the children tables. The first + table and then it draws the rows from the children tables. The first stage could fail if you try to do complex things. For example, Children.select(orderBy=Children.q.column, distinct=True) could fail because at the first stage inheritance generates a SELECT |
From: <sub...@co...> - 2010-02-01 14:45:17
|
Author: phd Date: 2010-02-01 07:45:04 -0700 (Mon, 01 Feb 2010) New Revision: 4090 Added: SQLObject/trunk/sqlobject/tests/test_sqlmeta_idName.py Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/main.py SQLObject/trunk/sqlobject/tests/test_basic.py Log: Do not pollute the base sqlmeta class to allow Style to set idName. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2010-01-22 17:54:29 UTC (rev 4089) +++ SQLObject/trunk/docs/News.txt 2010-02-01 14:45:04 UTC (rev 4090) @@ -16,6 +16,13 @@ * Added TimedeltaCol; currently it's only implemented on PostgreSQL as an INTERVAL type. +Small Features +-------------- + +* Do not pollute the base sqlmeta class to allow Style to set idName. In + the case of inherited idName inherited value takes precedence; To allow + Style to set idName resets inherited idName to None. + SQLObject 0.12.1 ================ Modified: SQLObject/trunk/sqlobject/main.py =================================================================== --- SQLObject/trunk/sqlobject/main.py 2010-01-22 17:54:29 UTC (rev 4089) +++ SQLObject/trunk/sqlobject/main.py 2010-02-01 14:45:04 UTC (rev 4090) @@ -853,7 +853,8 @@ del values[key] cls.sqlmeta = type('sqlmeta', (superclass,), values) - cls.sqlmeta.setClass(cls) + if not is_base: # Do not pollute the base sqlmeta class + cls.sqlmeta.setClass(cls) _SO_setupSqlmeta = classmethod(_SO_setupSqlmeta) Modified: SQLObject/trunk/sqlobject/tests/test_basic.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_basic.py 2010-01-22 17:54:29 UTC (rev 4089) +++ SQLObject/trunk/sqlobject/tests/test_basic.py 2010-02-01 14:45:04 UTC (rev 4090) @@ -291,29 +291,17 @@ else: assert 0, "Expected an AttributeError" -class myid_sqlmeta(sqlmeta): - idName = "my_id" - class TestSO12(SQLObject): - class sqlmeta(myid_sqlmeta): - pass name = StringCol() - -def test_sqlmeta_inherited_idName(): - setupClass(TestSO12) - assert TestSO12.sqlmeta.idName == "my_id" - -class TestSO13(SQLObject): - name = StringCol() value = IntCol(defaultSQL='1') def test_defaultSQL(): - setupClass(TestSO13) - test = TestSO13(name="test") + setupClass(TestSO12) + test = TestSO12(name="test") assert test.value == 1 def test_connection_override(): sqlhub.processConnection = connectionForURI('sqlite:///db1') - class TestSO14(SQLObject): + class TestSO13(SQLObject): _connection = connectionForURI('sqlite:///db2') - assert TestSO14._connection.uri() == 'sqlite:///db2' + assert TestSO13._connection.uri() == 'sqlite:///db2' Added: SQLObject/trunk/sqlobject/tests/test_sqlmeta_idName.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_sqlmeta_idName.py (rev 0) +++ SQLObject/trunk/sqlobject/tests/test_sqlmeta_idName.py 2010-02-01 14:45:04 UTC (rev 4090) @@ -0,0 +1,43 @@ +from sqlobject import * +from sqlobject.tests.dbtest import * + +class myid_sqlmeta(sqlmeta): + idName = "my_id" + +class TestSqlmeta1(SQLObject): + class sqlmeta(myid_sqlmeta): + pass + +class TestSqlmeta2(SQLObject): + class sqlmeta(sqlmeta): + style = MixedCaseStyle(longID=True) + +class TestSqlmeta3(SQLObject): + class sqlmeta(myid_sqlmeta): + style = MixedCaseStyle(longID=True) + +class TestSqlmeta4(SQLObject): + class sqlmeta(myid_sqlmeta): + idName = None + style = MixedCaseStyle(longID=True) + +class longid_sqlmeta(sqlmeta): + idName = "my_id" + style = MixedCaseStyle(longID=True) + +class TestSqlmeta5(SQLObject): + class sqlmeta(longid_sqlmeta): + pass + +class TestSqlmeta6(SQLObject): + class sqlmeta(longid_sqlmeta): + idName = None + +def test_sqlmeta_inherited_idName(): + setupClass([TestSqlmeta1, TestSqlmeta2]) + assert TestSqlmeta1.sqlmeta.idName == "my_id" + assert TestSqlmeta2.sqlmeta.idName == "TestSqlmeta2ID" + assert TestSqlmeta3.sqlmeta.idName == "my_id" + assert TestSqlmeta4.sqlmeta.idName == "TestSqlmeta4ID" + assert TestSqlmeta5.sqlmeta.idName == "my_id" + assert TestSqlmeta6.sqlmeta.idName == "TestSqlmeta6ID" |
From: <sub...@co...> - 2010-01-22 17:54:40
|
Author: phd Date: 2010-01-22 10:54:29 -0700 (Fri, 22 Jan 2010) New Revision: 4089 Modified: SQLObject/trunk/sqlobject/main.py Log: SQLObject requires Python 2.4.0 or later. Modified: SQLObject/trunk/sqlobject/main.py =================================================================== --- SQLObject/trunk/sqlobject/main.py 2010-01-15 16:11:54 UTC (rev 4088) +++ SQLObject/trunk/sqlobject/main.py 2010-01-22 17:54:29 UTC (rev 4089) @@ -44,8 +44,8 @@ from util.threadinglocal import local import sys -if sys.version_info[:3] < (2, 2, 0): - raise ImportError, "SQLObject requires Python 2.2.0 or later" +if sys.version_info[:3] < (2, 4, 0): + raise ImportError, "SQLObject requires Python 2.4.0 or later" """ This thread-local storage is needed for RowCreatedSignals. It gathers |
From: <sub...@co...> - 2010-01-15 16:12:12
|
Author: phd Date: 2010-01-15 09:11:54 -0700 (Fri, 15 Jan 2010) New Revision: 4088 Modified: SQLObject/trunk/docs/News.txt SQLObject/trunk/sqlobject/col.py SQLObject/trunk/sqlobject/converters.py SQLObject/trunk/sqlobject/tests/test_converters.py Log: Added TimedeltaCol; currently it's only implemented on PostgreSQL as an INTERVAL type. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2010-01-08 21:26:15 UTC (rev 4087) +++ SQLObject/trunk/docs/News.txt 2010-01-15 16:11:54 UTC (rev 4088) @@ -10,6 +10,12 @@ SQLObject (trunk) ================= +Features & Interface +-------------------- + +* Added TimedeltaCol; currently it's only implemented on PostgreSQL as an + INTERVAL type. + SQLObject 0.12.1 ================ Modified: SQLObject/trunk/sqlobject/col.py =================================================================== --- SQLObject/trunk/sqlobject/col.py 2010-01-08 21:26:15 UTC (rev 4087) +++ SQLObject/trunk/sqlobject/col.py 2010-01-15 16:11:54 UTC (rev 4088) @@ -1283,6 +1283,25 @@ baseClass = SOTimestampCol +class TimedeltaValidator(validators.Validator): + def to_python(self, value, state): + return value + + def from_python(self, value, state): + return value + +class SOTimedeltaCol(SOCol): + def _postgresType(self): + return 'INTERVAL' + + def createValidators(self): + return [TimedeltaValidator(name=self.name)] + \ + super(SOTimedeltaCol, self).createValidators() + +class TimedeltaCol(Col): + baseClass = SOTimedeltaCol + + from decimal import Decimal class DecimalValidator(validators.Validator): Modified: SQLObject/trunk/sqlobject/converters.py =================================================================== --- SQLObject/trunk/sqlobject/converters.py 2010-01-08 21:26:15 UTC (rev 4087) +++ SQLObject/trunk/sqlobject/converters.py 2010-01-15 16:11:54 UTC (rev 4088) @@ -187,6 +187,14 @@ registerConverter(Decimal, DecimalConverter) +def TimedeltaConverter(value, db): + + return """INTERVAL '%d days %d seconds'""" % \ + (value.days, value.seconds) + +registerConverter(datetime.timedelta, TimedeltaConverter) + + def sqlrepr(obj, db=None): try: reprFunc = obj.__sqlrepr__ Modified: SQLObject/trunk/sqlobject/tests/test_converters.py =================================================================== --- SQLObject/trunk/sqlobject/tests/test_converters.py 2010-01-08 21:26:15 UTC (rev 4087) +++ SQLObject/trunk/sqlobject/tests/test_converters.py 2010-01-15 16:11:54 UTC (rev 4088) @@ -1,4 +1,5 @@ import sys +from datetime import timedelta from sqlobject.sqlbuilder import sqlrepr from sqlobject.sqlbuilder import SQLExpression, SQLObjectField, \ Select, Insert, Update, Delete, Replace, \ @@ -195,3 +196,7 @@ pass else: assert sqlrepr(Set([1])) == "(1)" + +def test_timedelta(): + assert sqlrepr(timedelta(seconds=30*60)) == \ + "INTERVAL '0 days 1800 seconds'" |
From: <sub...@co...> - 2010-01-08 21:26:22
|
Author: phd Date: 2010-01-08 14:26:15 -0700 (Fri, 08 Jan 2010) New Revision: 4087 Modified: SQLObject/trunk/docs/News.txt Log: SQLObject 0.11.3 and 0.12.1 were released 8 Jan 2010. Modified: SQLObject/trunk/docs/News.txt =================================================================== --- SQLObject/trunk/docs/News.txt 2010-01-08 21:25:33 UTC (rev 4086) +++ SQLObject/trunk/docs/News.txt 2010-01-08 21:26:15 UTC (rev 4087) @@ -13,6 +13,8 @@ SQLObject 0.12.1 ================ +Released 8 Jan 2010. + * Fixed three bugs in PostgresConnection. * A number of changes ported from `SQLObject 0.11.3`_. @@ -70,6 +72,8 @@ SQLObject 0.11.3 ================ +Released 8 Jan 2010. + * Fixed a bug in col.py and dbconnection.py - if dbEncoding is None suppose it's 'ascii'. |
From: <sub...@co...> - 2010-01-08 21:25:39
|
Author: phd Date: 2010-01-08 14:25:33 -0700 (Fri, 08 Jan 2010) New Revision: 4086 Modified: SQLObject/branches/0.12/docs/News.txt Log: SQLObject 0.11.3 and 0.12.1 were released 8 Jan 2010. Modified: SQLObject/branches/0.12/docs/News.txt =================================================================== --- SQLObject/branches/0.12/docs/News.txt 2010-01-08 21:23:52 UTC (rev 4085) +++ SQLObject/branches/0.12/docs/News.txt 2010-01-08 21:25:33 UTC (rev 4086) @@ -10,6 +10,8 @@ SQLObject 0.12.1 ================ +Released 8 Jan 2010. + * Fixed three bugs in PostgresConnection. * A number of changes ported from `SQLObject 0.11.3`_. @@ -67,6 +69,8 @@ SQLObject 0.11.3 ================ +Released 8 Jan 2010. + * Fixed a bug in col.py and dbconnection.py - if dbEncoding is None suppose it's 'ascii'. |
From: <sub...@co...> - 2010-01-08 21:24:00
|
Author: phd Date: 2010-01-08 14:23:52 -0700 (Fri, 08 Jan 2010) New Revision: 4085 Modified: SQLObject/branches/0.11/docs/News.txt Log: SQLObject 0.11.3 was released 8 Jan 2010. Modified: SQLObject/branches/0.11/docs/News.txt =================================================================== --- SQLObject/branches/0.11/docs/News.txt 2010-01-08 12:27:09 UTC (rev 4084) +++ SQLObject/branches/0.11/docs/News.txt 2010-01-08 21:23:52 UTC (rev 4085) @@ -10,6 +10,8 @@ SQLObject 0.11.3 ================ +Released 8 Jan 2010. + * Fixed a bug in col.py and dbconnection.py - if dbEncoding is None suppose it's 'ascii'. |