sqlobject-cvs Mailing List for SQLObject (Page 109)
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
(1) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
|
From: SourceForge.net <no...@so...> - 2007-01-10 14:40:20
|
Bugs item #1610027, was opened at 2006-12-06 14:57 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1610027&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: General Group: SQLObject release (specify) >Status: Closed >Resolution: Wont Fix Priority: 5 Private: No Submitted By: Michael Lang (nuddelaug) Assigned to: Oleg Broytmann (phd) Summary: Memory Leak SQLObject-0.7.2 Initial Comment: Hi, i've used SQLObject on ubuntu with sqlite and found a strange behavior consuming the machine memory where it shouldnt do. i wrote a script which creates 2 Tables mostly stringcol, i then iter over a list of names inserting them into just one table buy creating a new Object from the Class for my table, after inserting the values i even del the Object but the memoryuseage increases still <code snip> while [ 1 ]: line = sys.stdin.readline() if not line: break tbl = Table2(col1="a", col2="b", col3="c", ... ) del tbl <code snip> im a getting something wrong ? the data gets inserted, sqlite> SELECT count(*) FROM table2; 117760 but after these Records the machine craps up in swaping due ~350M memory usage on 512M Machine running other things to. thanks for any help kind regards Michael lang ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-01-10 17:40 Message: Logged In: YES user_id=4799 Originator: NO No, an SQLObject should not clear the entire cache - it is application's task. ---------------------------------------------------------------------- Comment By: Michael Lang (nuddelaug) Date: 2006-12-12 13:41 Message: Logged In: YES user_id=1216160 Originator: YES Hi olec, yes that helps and saves my memory :) maybe you can apply an automatic clean on object destruction like attached below. thanks for your fast response. kind regards Michael Lang --- /usr/lib/python2.4/site-packages/sqlobject/main.py 2004-10-20 22:28:18.000000000 +0200 +++ /tmp/main.py 2006-12-12 11:38:03.000000000 +0100 @@ -331,6 +331,10 @@ # aren't using integer IDs _idType = int + def __del__(self): + # cleanup cache before wiping object + self._connection.cache.clear() + def get(cls, id, connection=None, selectResults=None): assert id is not None, 'None is not a possible id for %s' % cls.__name ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-12-11 19:12 Message: Logged In: YES user_id=4799 Originator: NO The rows you draw from the table are put in the cache, and are not removed with "del tbl". How many rows have you selected? The cache is being culled after selecting 100 rows (after every 100 rows). You can change the culling frequency or clear the cache yourself: Table2._connection.cache.clear(). Does it help? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1610027&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-10 14:36:53
|
Patches item #1630441, was opened at 2007-01-08 13:39 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1630441&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: Mike Vorozhbensky (mgfox) >Assigned to: Oleg Broytmann (phd) Summary: revision 2150 firebird connectionFromURI *NIX db alias usage Initial Comment: when i try to use URI like "firebird://localhost/database" (database - database alias) in linux, i see error: --- cut --- File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/sresults.py", line 160, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/sresults.py", line 168, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/dbconnection.py", line 373, in iterSelect return select.IterationClass(self, self.getConnection(), File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/dbconnection.py", line 239, in getConnection conn = self.makeConnection() File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/firebird/firebirdconnection.py", line 87, in makeConnection charset=self.charset, File "/var/lib/python-support/python2.4/kinterbasdb/__init__.py", line 472, in connect return Connection(*args, **keywords_args) File "/var/lib/python-support/python2.4/kinterbasdb/__init__.py", line 610, in __init__ self._C_con = _k.attach_db(dsn, dpb, dialect) OperationalError: (-902, 'isc_attach_database: I/O error for file "/database". Error while trying to open file. No such file or directory. ') --- end cut --- path fix this problem ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-01-10 17:36 Message: Logged In: YES user_id=4799 Originator: NO Can I change if path[-3:].lower() != 'fdb' and path[-3:].lower() != 'gdb': to if path[-3:].lower() not in ('fdb', 'gdb'): ? ---------------------------------------------------------------------- Comment By: Mike Vorozhbensky (mgfox) Date: 2007-01-08 13:49 Message: Logged In: YES user_id=1240394 Originator: YES bug also present in revision 2175 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1630441&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-10 14:33:27
|
Patches item #1621211, was opened at 2006-12-23 13:42 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1621211&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: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Mike Vorozhbensky (mgfox) >Assigned to: Oleg Broytmann (phd) Summary: revision 2150 firebird fromDatabase - error in field names Initial Comment: when creating object from firebird database field names generated with extra spaces like "COMMENT " ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-01-10 17:33 Message: Logged In: YES user_id=4799 Originator: NO Applied to all branches (0.7, 0.8, trunk) in the revisions 2190-2193. Thank you! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1621211&group_id=74338 |
|
From: <sub...@co...> - 2007-01-10 14:32:09
|
Author: phd
Date: 2007-01-10 07:32:03 -0700 (Wed, 10 Jan 2007)
New Revision: 2194
Modified:
home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py
Log:
Merged patches from the revisions 2189:2193 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:30:56 UTC (rev 2193)
+++ home/phd/SQLObject/paramstyles/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:32:03 UTC (rev 2194)
@@ -193,8 +193,8 @@
if field == 'id':
continue
colClass, kw = self.guessClass(t, flength, fscale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field).strip()
+ kw['dbName'] = field.strip()
kw['notNone'] = not nullAllowed
kw['default'] = thedefault
results.append(colClass(**kw))
|
|
From: <sub...@co...> - 2007-01-10 14:31:11
|
Author: phd
Date: 2007-01-10 07:30:56 -0700 (Wed, 10 Jan 2007)
New Revision: 2193
Modified:
SQLObject/branches/0.8/sqlobject/firebird/firebirdconnection.py
Log:
Fixed a bug in FirebirdConnection caused by column names having trailing spaces (patch 1621211).
Modified: SQLObject/branches/0.8/sqlobject/firebird/firebirdconnection.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:30:41 UTC (rev 2192)
+++ SQLObject/branches/0.8/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:30:56 UTC (rev 2193)
@@ -195,8 +195,8 @@
if field == 'id':
continue
colClass, kw = self.guessClass(t, flength, fscale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field).strip()
+ kw['dbName'] = field.strip()
kw['notNone'] = not nullAllowed
kw['default'] = thedefault
results.append(colClass(**kw))
|
|
From: <sub...@co...> - 2007-01-10 14:30:49
|
Author: phd
Date: 2007-01-10 07:30:41 -0700 (Wed, 10 Jan 2007)
New Revision: 2192
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py
Log:
Fixed a bug in FirebirdConnection caused by column names having trailing spaces (patch 1621211).
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-10 14:30:17 UTC (rev 2191)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-10 14:30:41 UTC (rev 2192)
@@ -19,6 +19,9 @@
* Fixed a bug in MSSQLConnection caused by column names being unicode.
+* Fixed a bug in FirebirdConnection caused by column names having trailing
+ spaces.
+
SQLObject 0.7.2
===============
Modified: SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:30:17 UTC (rev 2191)
+++ SQLObject/branches/0.7-bugfix/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:30:41 UTC (rev 2192)
@@ -190,8 +190,8 @@
if field == 'id':
continue
colClass, kw = self.guessClass(t, flength, fscale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field).strip()
+ kw['dbName'] = field.strip()
kw['notNone'] = not nullAllowed
kw['default'] = thedefault
results.append(colClass(**kw))
|
|
From: <sub...@co...> - 2007-01-10 14:30:25
|
Author: phd Date: 2007-01-10 07:30:17 -0700 (Wed, 10 Jan 2007) New Revision: 2191 Modified: SQLObject/docs/News.txt Log: Fixed a bug in FirebirdConnection caused by column names having trailing spaces (patch 1621211). Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-01-10 14:29:26 UTC (rev 2190) +++ SQLObject/docs/News.txt 2007-01-10 14:30:17 UTC (rev 2191) @@ -134,6 +134,9 @@ * Fixed a bug in MSSQLConnection caused by column names being unicode. +* Fixed a bug in FirebirdConnection caused by column names having trailing + spaces. + SQLObject 0.7.3 =============== |
|
From: <sub...@co...> - 2007-01-10 14:29:31
|
Author: phd
Date: 2007-01-10 07:29:26 -0700 (Wed, 10 Jan 2007)
New Revision: 2190
Modified:
SQLObject/trunk/sqlobject/firebird/firebirdconnection.py
Log:
Fixed a bug in FirebirdConnection caused by column names having trailing spaces (patch 1621211).
Modified: SQLObject/trunk/sqlobject/firebird/firebirdconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:19:12 UTC (rev 2189)
+++ SQLObject/trunk/sqlobject/firebird/firebirdconnection.py 2007-01-10 14:29:26 UTC (rev 2190)
@@ -193,8 +193,8 @@
if field == 'id':
continue
colClass, kw = self.guessClass(t, flength, fscale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field).strip()
+ kw['dbName'] = field.strip()
kw['notNone'] = not nullAllowed
kw['default'] = thedefault
results.append(colClass(**kw))
|
|
From: <sub...@co...> - 2007-01-10 14:19:15
|
Author: phd
Date: 2007-01-10 07:19:12 -0700 (Wed, 10 Jan 2007)
New Revision: 2189
Added:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py
Modified:
home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
home/phd/SQLObject/paramstyles/sqlobject/main.py
Log:
Merged patches from the revisions 2187:2188 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2007-01-10 14:15:22 UTC (rev 2188)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/__init__.py 2007-01-10 14:19:12 UTC (rev 2189)
@@ -1,6 +1,6 @@
from sqlobject import sqlbuilder
from sqlobject import classregistry
-from sqlobject.col import StringCol, ForeignKey
+from sqlobject.col import StringCol, ForeignKey, BoolCol
from sqlobject.main import sqlmeta, SQLObject, SelectResults, True, False, \
makeProperties, getterName, setterName
import iteration
@@ -63,6 +63,12 @@
parentClause.append(currentClass.q.id == parentClass.q.id)
currentClass = parentClass
tablesDict[currentClass.sqlmeta.table] = 1
+
+ for (currentClass, minParentClass) in tableRegistry.items():
+ if InheritableSQLObject in minParentClass.__bases__:
+ parentClause.append(minParentClass.q.doneConstructing == True)
+ break
+
clause = reduce(sqlbuilder.AND, parentClause, clause)
super(InheritableSelectResults, self).__init__(sourceClass,
@@ -192,7 +198,7 @@
currentClass = cls.sqlmeta.parentClass
while currentClass:
for column in currentClass.sqlmeta.columnDefinitions.values():
- if column.name == 'childName':
+ if column.name == 'doneConstructing' or column.name == 'childName':
continue
if type(column) == ForeignKey:
continue
@@ -290,6 +296,12 @@
sqlmeta.addColumn(StringCol(name='childName',
# limit string length to get VARCHAR and not CLOB
length=255, default=None))
+
+ #only on top-level classes
+ if InheritableSQLObject in cls.__bases__:
+ #add the doneConstructing column to make half-constructed tasks invisible
+ sqlmeta.addColumn(BoolCol(name='doneConstructing', default=False))
+
if not sqlmeta.columnList:
# There are no columns - call addColumn to propagate columns
# from parent classes to children
@@ -300,7 +312,7 @@
sqlmeta.addJoin(None)
_notifyFinishClassCreation = classmethod(_notifyFinishClassCreation)
- def _create(self, id, **kw):
+ def _create(self, id, last_derived=False, **kw):
#DSM: If we were called by a children class,
#DSM: we must retreive the properties dictionary.
@@ -331,7 +343,7 @@
raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name)
parent_kw['childName'] = self.sqlmeta.childName
- self._parent = parentClass(kw=parent_kw,
+ self._parent = parentClass(last_derived=False, kw=parent_kw,
connection=self._connection)
id = self._parent.id
Copied: home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py (from rev 2188, SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py)
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py (rev 0)
+++ home/phd/SQLObject/paramstyles/sqlobject/inheritance/tests/test_encapsulate_hiding.py 2007-01-10 14:19:12 UTC (rev 2189)
@@ -0,0 +1,48 @@
+from py.test import raises
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+def first_position():
+ employees = Employee.select()
+ if employees.count():
+ return employees[0].position
+ else:
+ return "Lackey"
+
+def first_floor():
+ janitors = Janitor.select()
+ if janitors.count():
+ return janitors[0].floor
+ else:
+ return 0
+
+
+class InheritablePerson(InheritableSQLObject):
+ firstName = StringCol()
+ lastName = StringCol(alternateID=True, length=255)
+
+class Employee(InheritablePerson):
+ position = StringCol(default=first_position)
+
+class Janitor(Employee):
+ _inheritable = False
+ floor = IntCol(default=first_floor)
+
+def setup():
+ setupClass(InheritablePerson)
+ setupClass(Employee)
+ setupClass(Janitor)
+
+def test_liveness():
+
+ setup()
+ emp = Employee(firstName='Igor', lastName='Humpback')
+ assert emp.position == "Lackey"
+ emp.position = "Grunt"
+
+ emp = Employee(firstName='Frank', lastName='Furter')
+ assert emp.position == "Grunt"
+
+ jan = Janitor(firstName="George", lastName="Bush")
+ assert jan.floor == 0
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-01-10 14:15:22 UTC (rev 2188)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-01-10 14:19:12 UTC (rev 2189)
@@ -1203,7 +1203,7 @@
else:
return joinClass.get(id)
- def __init__(self, **kw):
+ def __init__(self, last_derived = True, **kw):
# We shadow the sqlmeta class with an instance of sqlmeta
# that points to us (our sqlmeta buddy object; where the
# sqlmeta class is our class's buddy class)
@@ -1231,12 +1231,15 @@
else:
id = None
- self._create(id, **kw)
+ self._create(id, last_derived=False, **kw)
+
+ if last_derived and hasattr(self, 'doneConstructing'):
+ self.doneConstructing = True
+
for func in post_funcs:
func(self)
- def _create(self, id, **kw):
-
+ def _create(self, id, last_derived=False,**kw):
self.sqlmeta._creating = True
self._SO_createValues = {}
self._SO_validatorState = SQLObjectState(self)
|
|
From: <sub...@co...> - 2007-01-10 14:15:32
|
Author: phd
Date: 2007-01-10 07:15:22 -0700 (Wed, 10 Jan 2007)
New Revision: 2188
Added:
SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
SQLObject/trunk/sqlobject/main.py
Log:
Patch 614267: Prevents half-constructed objects from showing up in queries.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-01-10 13:41:05 UTC (rev 2187)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2007-01-10 14:15:22 UTC (rev 2188)
@@ -1,6 +1,6 @@
from sqlobject import sqlbuilder
from sqlobject import classregistry
-from sqlobject.col import StringCol, ForeignKey
+from sqlobject.col import StringCol, ForeignKey, BoolCol
from sqlobject.main import sqlmeta, SQLObject, SelectResults, True, False, \
makeProperties, getterName, setterName
import iteration
@@ -63,6 +63,12 @@
parentClause.append(currentClass.q.id == parentClass.q.id)
currentClass = parentClass
tablesDict[currentClass.sqlmeta.table] = 1
+
+ for (currentClass, minParentClass) in tableRegistry.items():
+ if InheritableSQLObject in minParentClass.__bases__:
+ parentClause.append(minParentClass.q.doneConstructing == True)
+ break
+
clause = reduce(sqlbuilder.AND, parentClause, clause)
super(InheritableSelectResults, self).__init__(sourceClass,
@@ -192,7 +198,7 @@
currentClass = cls.sqlmeta.parentClass
while currentClass:
for column in currentClass.sqlmeta.columnDefinitions.values():
- if column.name == 'childName':
+ if column.name == 'doneConstructing' or column.name == 'childName':
continue
if type(column) == ForeignKey:
continue
@@ -290,6 +296,12 @@
sqlmeta.addColumn(StringCol(name='childName',
# limit string length to get VARCHAR and not CLOB
length=255, default=None))
+
+ #only on top-level classes
+ if InheritableSQLObject in cls.__bases__:
+ #add the doneConstructing column to make half-constructed tasks invisible
+ sqlmeta.addColumn(BoolCol(name='doneConstructing', default=False))
+
if not sqlmeta.columnList:
# There are no columns - call addColumn to propagate columns
# from parent classes to children
@@ -300,7 +312,7 @@
sqlmeta.addJoin(None)
_notifyFinishClassCreation = classmethod(_notifyFinishClassCreation)
- def _create(self, id, **kw):
+ def _create(self, id, last_derived=False, **kw):
#DSM: If we were called by a children class,
#DSM: we must retreive the properties dictionary.
@@ -331,7 +343,7 @@
raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, col.name)
parent_kw['childName'] = self.sqlmeta.childName
- self._parent = parentClass(kw=parent_kw,
+ self._parent = parentClass(last_derived=False, kw=parent_kw,
connection=self._connection)
id = self._parent.id
Added: SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py (rev 0)
+++ SQLObject/trunk/sqlobject/inheritance/tests/test_encapsulate_hiding.py 2007-01-10 14:15:22 UTC (rev 2188)
@@ -0,0 +1,48 @@
+from py.test import raises
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+from sqlobject.inheritance import InheritableSQLObject
+
+def first_position():
+ employees = Employee.select()
+ if employees.count():
+ return employees[0].position
+ else:
+ return "Lackey"
+
+def first_floor():
+ janitors = Janitor.select()
+ if janitors.count():
+ return janitors[0].floor
+ else:
+ return 0
+
+
+class InheritablePerson(InheritableSQLObject):
+ firstName = StringCol()
+ lastName = StringCol(alternateID=True, length=255)
+
+class Employee(InheritablePerson):
+ position = StringCol(default=first_position)
+
+class Janitor(Employee):
+ _inheritable = False
+ floor = IntCol(default=first_floor)
+
+def setup():
+ setupClass(InheritablePerson)
+ setupClass(Employee)
+ setupClass(Janitor)
+
+def test_liveness():
+
+ setup()
+ emp = Employee(firstName='Igor', lastName='Humpback')
+ assert emp.position == "Lackey"
+ emp.position = "Grunt"
+
+ emp = Employee(firstName='Frank', lastName='Furter')
+ assert emp.position == "Grunt"
+
+ jan = Janitor(firstName="George", lastName="Bush")
+ assert jan.floor == 0
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2007-01-10 13:41:05 UTC (rev 2187)
+++ SQLObject/trunk/sqlobject/main.py 2007-01-10 14:15:22 UTC (rev 2188)
@@ -1203,7 +1203,7 @@
else:
return joinClass.get(id)
- def __init__(self, **kw):
+ def __init__(self, last_derived = True, **kw):
# We shadow the sqlmeta class with an instance of sqlmeta
# that points to us (our sqlmeta buddy object; where the
# sqlmeta class is our class's buddy class)
@@ -1231,12 +1231,15 @@
else:
id = None
- self._create(id, **kw)
+ self._create(id, last_derived=False, **kw)
+
+ if last_derived and hasattr(self, 'doneConstructing'):
+ self.doneConstructing = True
+
for func in post_funcs:
func(self)
- def _create(self, id, **kw):
-
+ def _create(self, id, last_derived=False,**kw):
self.sqlmeta._creating = True
self._SO_createValues = {}
self._SO_validatorState = SQLObjectState(self)
|
|
From: <sub...@co...> - 2007-01-10 13:41:10
|
Author: phd
Date: 2007-01-10 06:41:05 -0700 (Wed, 10 Jan 2007)
New Revision: 2187
Modified:
home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py
Log:
Merged patches from the revisions 2182:2186 from the trunk: fixed a bug in MSSQLConnection caused by column names being unicode (patch 1613369).
Modified: home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py 2007-01-10 13:36:30 UTC (rev 2186)
+++ home/phd/SQLObject/paramstyles/sqlobject/mssql/mssqlconnection.py 2007-01-10 13:41:05 UTC (rev 2187)
@@ -220,8 +220,8 @@
continue
# precision is needed for decimal columns
colClass, kw = self.guessClass(t, size, precision, scale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = str(soClass.sqlmeta.style.dbColumnToPythonAttr(field))
+ kw['dbName'] = str(field)
kw['notNone'] = not nullAllowed
if (defaultText):
# Strip ( and )
|
|
From: SourceForge.net <no...@so...> - 2007-01-10 13:40:18
|
Patches item #1613369, was opened at 2006-12-11 20:44 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1613369&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: Closed >Resolution: Accepted Priority: 5 Private: No Submitted By: Paul Johnston (paj28) >Assigned to: Oleg Broytmann (phd) Summary: Fix bug that breaks "tg-admin sql status" Initial Comment: I was unable to get "tg-admin sql status" to work; I've attached the exception at the bottom. The problem is that in sqlbuilder.py, in the function sqlIdentifier, it does a check like 'type(obj) is type("")'. In this case the object in unicode, which incorrectly causes a failure. The fix is to replace the check with isinstance(obj, basestring). C:\tsrweb>tg-admin sql status Using database URI mssql://pythonweb:mdi*2mdO1@./giitr Traceback (most recent call last): File "c:\python24\scripts\tg-admin-script.py", line 7, in ? sys.exit( File "c:\python24\lib\site-packages\TurboGears-1.0b2-py2.4.egg\turbogears\comm and\base.py", line 358, in main command.run() File "c:\python24\lib\site-packages\TurboGears-1.0b2-py2.4.egg\turbogears\comm and\base.py", line 144, in run command.the_runner.run(sys.argv) File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\manage r\command.py", line 102, in run runner.run() File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\manage r\command.py", line 233, in run self.command() File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\manage r\command.py", line 663, in command col = col.withClass(soClass) File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py ", line 410, in withClass extra_vars=self._extra_vars, File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py ", line 558, in __init__ super(SOUnicodeCol, self).__init__(**kw) File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py ", line 439, in __init__ super(SOStringLikeCol, self).__init__(**kw) File "c:\python24\lib\site-packages\SQLObject-0.7.2-py2.4.egg\sqlobject\col.py ", line 143, in __init__ assert sqlbuilder.sqlIdentifier(name), 'Name must be SQL-safe (letters, numb ers, underscores): %s (or use forceDBName=True)' \ AssertionError: Name must be SQL-safe (letters, numbers, underscores): u'capword ' (or use forceDBName=True) ---------------------------------------------------------------------- >Comment By: Oleg Broytmann (phd) Date: 2007-01-10 16:40 Message: Logged In: YES user_id=4799 Originator: NO Applied to all branches (0.7, 0.8, trunk) in the revisions 2183-2186. Thank you! ---------------------------------------------------------------------- Comment By: Paul Johnston (paj28) Date: 2006-12-12 22:36 Message: Logged In: YES user_id=1051055 Originator: YES After discussion on the list, here's an alternative patch. File Added: mssqlconnection.py.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1613369&group_id=74338 |
|
From: <sub...@co...> - 2007-01-10 13:36:32
|
Author: phd
Date: 2007-01-10 06:36:30 -0700 (Wed, 10 Jan 2007)
New Revision: 2186
Modified:
SQLObject/branches/0.7-bugfix/docs/News.txt
SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py
Log:
Fixed a bug in MSSQLConnection caused by column names being unicode (patch 1613369).
Modified: SQLObject/branches/0.7-bugfix/docs/News.txt
===================================================================
--- SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-10 13:36:15 UTC (rev 2185)
+++ SQLObject/branches/0.7-bugfix/docs/News.txt 2007-01-10 13:36:30 UTC (rev 2186)
@@ -17,6 +17,8 @@
* Psycopg1 requires port to be a string; psycopg2 requires port to be an int.
+* Fixed a bug in MSSQLConnection caused by column names being unicode.
+
SQLObject 0.7.2
===============
Modified: SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py 2007-01-10 13:36:15 UTC (rev 2185)
+++ SQLObject/branches/0.7-bugfix/sqlobject/mssql/mssqlconnection.py 2007-01-10 13:36:30 UTC (rev 2186)
@@ -216,8 +216,8 @@
continue
# precision is needed for decimal columns
colClass, kw = self.guessClass(t, size, precision, scale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = str(soClass.sqlmeta.style.dbColumnToPythonAttr(field))
+ kw['dbName'] = str(field)
kw['notNone'] = not nullAllowed
if (defaultText):
# Strip ( and )
|
|
From: <sub...@co...> - 2007-01-10 13:36:20
|
Author: phd
Date: 2007-01-10 06:36:15 -0700 (Wed, 10 Jan 2007)
New Revision: 2185
Modified:
SQLObject/branches/0.8/sqlobject/mssql/mssqlconnection.py
Log:
Fixed a bug in MSSQLConnection caused by column names being unicode (patch 1613369).
Modified: SQLObject/branches/0.8/sqlobject/mssql/mssqlconnection.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/mssql/mssqlconnection.py 2007-01-10 13:35:49 UTC (rev 2184)
+++ SQLObject/branches/0.8/sqlobject/mssql/mssqlconnection.py 2007-01-10 13:36:15 UTC (rev 2185)
@@ -222,8 +222,8 @@
continue
# precision is needed for decimal columns
colClass, kw = self.guessClass(t, size, precision, scale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = str(soClass.sqlmeta.style.dbColumnToPythonAttr(field))
+ kw['dbName'] = str(field)
kw['notNone'] = not nullAllowed
if (defaultText):
# Strip ( and )
|
|
From: <sub...@co...> - 2007-01-10 13:35:55
|
Author: phd Date: 2007-01-10 06:35:49 -0700 (Wed, 10 Jan 2007) New Revision: 2184 Modified: SQLObject/docs/News.txt Log: Fixed a bug in MSSQLConnection caused by column names being unicode (patch 1613369). Modified: SQLObject/docs/News.txt =================================================================== --- SQLObject/docs/News.txt 2007-01-10 13:35:28 UTC (rev 2183) +++ SQLObject/docs/News.txt 2007-01-10 13:35:49 UTC (rev 2184) @@ -132,6 +132,8 @@ * Another round of bugfixes for MySQL errors 2006 and 2013 (SERVER_GONE, SERVER_LOST). +* Fixed a bug in MSSQLConnection caused by column names being unicode. + SQLObject 0.7.3 =============== |
|
From: <sub...@co...> - 2007-01-10 13:35:32
|
Author: phd
Date: 2007-01-10 06:35:28 -0700 (Wed, 10 Jan 2007)
New Revision: 2183
Modified:
SQLObject/trunk/sqlobject/mssql/mssqlconnection.py
Log:
Fixed a bug in MSSQLConnection caused by column names being unicode (patch 1613369).
Modified: SQLObject/trunk/sqlobject/mssql/mssqlconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/mssql/mssqlconnection.py 2007-01-10 02:57:59 UTC (rev 2182)
+++ SQLObject/trunk/sqlobject/mssql/mssqlconnection.py 2007-01-10 13:35:28 UTC (rev 2183)
@@ -220,8 +220,8 @@
continue
# precision is needed for decimal columns
colClass, kw = self.guessClass(t, size, precision, scale)
- kw['name'] = soClass.sqlmeta.style.dbColumnToPythonAttr(field)
- kw['dbName'] = field
+ kw['name'] = str(soClass.sqlmeta.style.dbColumnToPythonAttr(field))
+ kw['dbName'] = str(field)
kw['notNone'] = not nullAllowed
if (defaultText):
# Strip ( and )
|
|
From: <sub...@co...> - 2007-01-09 16:30:27
|
Author: phd
Date: 2007-01-09 09:30:12 -0700 (Tue, 09 Jan 2007)
New Revision: 2181
Modified:
home/phd/SQLObject/paramstyles/sqlobject/main.py
home/phd/SQLObject/paramstyles/sqlobject/versioning/__init__.py
home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py
Log:
Merged patches from the revisions 2171:2180 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/main.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-01-09 16:28:16 UTC (rev 2180)
+++ home/phd/SQLObject/paramstyles/sqlobject/main.py 2007-01-09 16:30:12 UTC (rev 2181)
@@ -787,10 +787,6 @@
if connection and not hasattr(cls, '_connection'):
cls.setConnection(connection)
- # Now the class is in an essentially OK-state, so we can
- # set up any magic attributes:
- declarative.setup_attributes(cls, new_attrs)
-
# We have to check if there are columns in the inherited
# _columns where the attribute has been set to None in this
# class. If so, then we need to remove that column from
@@ -806,6 +802,10 @@
for column in implicitColumns:
cls.sqlmeta.addColumn(column)
+ # Now the class is in an essentially OK-state, so we can
+ # set up any magic attributes:
+ declarative.setup_attributes(cls, new_attrs)
+
if cls.sqlmeta.fromDatabase:
cls.sqlmeta.addColumnsFromDatabase()
Modified: home/phd/SQLObject/paramstyles/sqlobject/versioning/__init__.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/versioning/__init__.py 2007-01-09 16:28:16 UTC (rev 2180)
+++ home/phd/SQLObject/paramstyles/sqlobject/versioning/__init__.py 2007-01-09 16:30:12 UTC (rev 2181)
@@ -9,10 +9,36 @@
del values['dateArchived']
self.masterClass.get(self.masterID).set(**values)
+ def nextVersion(self):
+ version = self.select(AND(self.q.masterID == self.masterID, self.q.id > self.id), limit=1, orderBy=self.q.id)
+ if version.count():
+ return version[0]
+ else:
+ return self.master
+
+ def getChangedFields(self):
+ next = self.nextVersion()
+ columns = self.__class__.sqlmeta.columns
+ fields = []
+ for column in columns:
+ if column not in ["dateArchived", "id", "masterID"]:
+ if getattr(self, column) != getattr(next, column):
+ fields.append(column.title())
+
+ return fields
+
+ def select(cls, clause=None, *args, **kw):
+ if not getattr(cls, '_connection', None):
+ cls._connection = cls.masterClass._connection
+ return super(Version, cls).select(clause, *args, **kw)
+ select = classmethod(select)
+
def getColumns(columns, cls):
for column, defi in cls.sqlmeta.columnDefinitions.items():
- columns[column] = defi.__class__()
-
+ if column.endswith("ID") and isinstance(defi, ForeignKey):
+ column = column[:-2]
+ columns[column] = defi.__class__(**defi._kw)
+
#ascend heirarchy
if cls.sqlmeta.parentClass:
getColumns(columns, cls.sqlmeta.parentClass)
@@ -21,29 +47,30 @@
class Versioning(object):
def __init__(self):
pass
+
def __addtoclass__(self, soClass, name):
self.name = name
self.soClass = soClass
- self.versionClass = None
+
+ attrs = {'dateArchived': DateTimeCol(default=datetime.now),
+ 'master': ForeignKey(self.soClass.__name__),
+ 'masterClass' : self.soClass,
+ }
+
+ getColumns (attrs, self.soClass)
+
+ self.versionClass = type(self.soClass.__name__+'Versions',
+ (Version,),
+ attrs)
+
events.listen(self.createTable,
soClass, events.CreateTableSignal)
events.listen(self.rowUpdate, soClass,
events.RowUpdateSignal)
def createVersionTable(self, cls, conn):
- columns = {'dateArchived': DateTimeCol(default=datetime.now),
- 'masterID': IntCol(),
- 'masterClass' : self.soClass,
- }
+ self.versionClass.createTable(ifNotExists=True, connection=conn)
- getColumns (columns, self.soClass)
-
- self.versionClass = type(self.soClass.__name__+'Versions',
- (Version,),
- columns)
-
- self.versionClass.createTable(connection=conn)
-
def createTable(self, soClass, connection, extra_sql, post_funcs):
assert soClass is self.soClass
post_funcs.append(self.createVersionTable)
Modified: home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py 2007-01-09 16:28:16 UTC (rev 2180)
+++ home/phd/SQLObject/paramstyles/sqlobject/versioning/test/test_version.py 2007-01-09 16:30:12 UTC (rev 2181)
@@ -1,43 +1,55 @@
from py.test import raises
from sqlobject import *
-from sqlobject.tests.dbtest import *
+try:
+ sorted
+except NameError:
+ # For Python 2.2 and 2.3:
+ from sqlobject.events import sorted
from sqlobject.inheritance import InheritableSQLObject
from sqlobject.versioning import Versioning
+from sqlobject.tests.dbtest import *
from datetime import datetime
-def setup():
- setupClass(MyClass)
- setupClass(Base)
- setupClass(Child)
- setupClass(Government)
- setupClass(Monarchy)
- setupClass(VChild)
-
class MyClass(SQLObject):
- name = StringCol()
- versions = Versioning()
+ name = StringCol()
+ versions = Versioning()
class Base(InheritableSQLObject):
- name = StringCol()
- versions = Versioning()
+ name = StringCol()
+ value = IntCol(default=0)
+ versions = Versioning()
class Child(Base):
- toy = StringCol()
+ toy = StringCol()
-
class Government(InheritableSQLObject):
- name = StringCol()
+ name = StringCol()
class Monarchy(Government):
- monarch = StringCol()
- versions = Versioning()
+ monarch = StringCol()
+ versions = Versioning()
class VChild(Base):
weapon = StringCol()
versions = Versioning()
+class HasForeign(SQLObject):
+ foreign = ForeignKey("Base")
+ versions = Versioning()
+
+def setup():
+ for cls in [MyClass, Base, Child, Government, Monarchy, VChild, HasForeign]:
+ if hasattr(cls, 'versions') and hasattr(cls, "_connection") and \
+ cls._connection.tableExists(cls.sqlmeta.table):
+ setupClass(cls.versions.versionClass)
+ setupClass(cls)
+ if hasattr(cls, 'versions'):
+ setupClass(cls.versions.versionClass)
+ for version in cls.versions.versionClass.select():
+ version.destroySelf()
+
def test_versioning():
#the simple case
@@ -95,3 +107,28 @@
monarchy.versions[0].restore()
assert monarchy.name == "USA"
assert monarchy.monarch == "Emperor Norton I"
+
+def test_next():
+ setup()
+ base = Base(name='first', value=1)
+ base.set(name='second')
+ base.set(name='third', value=2)
+ version = base.versions[0]
+ assert version.nextVersion() == base.versions[1]
+ assert version.nextVersion().nextVersion() == base
+
+def test_get_changed():
+ setup()
+ base = Base(name='first', value=1)
+ base.set(name='second')
+ base.set(name='third', value=2)
+ assert base.versions[0].getChangedFields() == ['Name']
+ assert sorted(base.versions[1].getChangedFields()) == ['Name', 'Value']
+
+def test_foreign_keys():
+ setup()
+ base1 = Base(name='first', value=1)
+ base2 = Base(name='first', value=1)
+ has_foreign = HasForeign(foreign = base1)
+ has_foreign.foreign = base2
+ assert has_foreign.versions[0].foreign == base1
|
|
From: <sub...@co...> - 2007-01-09 16:28:31
|
Author: phd
Date: 2007-01-09 09:28:16 -0700 (Tue, 09 Jan 2007)
New Revision: 2180
Modified:
SQLObject/trunk/sqlobject/versioning/test/test_version.py
Log:
For backends that support referential integrity (Postgres, e.g.)
we have to clear the versioning table before clearing the main table.
Modified: SQLObject/trunk/sqlobject/versioning/test/test_version.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-09 16:14:09 UTC (rev 2179)
+++ SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-09 16:28:16 UTC (rev 2180)
@@ -1,6 +1,10 @@
from py.test import raises
from sqlobject import *
-from sqlobject.events import sorted
+try:
+ sorted
+except NameError:
+ # For Python 2.2 and 2.3:
+ from sqlobject.events import sorted
from sqlobject.inheritance import InheritableSQLObject
from sqlobject.versioning import Versioning
from sqlobject.tests.dbtest import *
@@ -8,14 +12,6 @@
from datetime import datetime
-def setup():
- for cls in [MyClass, Base, Child, Government, Monarchy, VChild, HasForeign]:
- setupClass(cls)
- if hasattr(cls, 'versions'):
- setupClass(cls.versions.versionClass)
- for version in cls.versions.versionClass.select():
- version.destroySelf()
-
class MyClass(SQLObject):
name = StringCol()
versions = Versioning()
@@ -43,6 +39,17 @@
foreign = ForeignKey("Base")
versions = Versioning()
+def setup():
+ for cls in [MyClass, Base, Child, Government, Monarchy, VChild, HasForeign]:
+ if hasattr(cls, 'versions') and hasattr(cls, "_connection") and \
+ cls._connection.tableExists(cls.sqlmeta.table):
+ setupClass(cls.versions.versionClass)
+ setupClass(cls)
+ if hasattr(cls, 'versions'):
+ setupClass(cls.versions.versionClass)
+ for version in cls.versions.versionClass.select():
+ version.destroySelf()
+
def test_versioning():
#the simple case
|
|
From: <sub...@co...> - 2007-01-09 16:14:30
|
Author: phd
Date: 2007-01-09 09:14:09 -0700 (Tue, 09 Jan 2007)
New Revision: 2179
Modified:
SQLObject/trunk/sqlobject/versioning/__init__.py
SQLObject/trunk/sqlobject/versioning/test/test_version.py
Log:
Downgraded versioning to Python 2.3.
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-08 21:32:46 UTC (rev 2178)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-09 16:14:09 UTC (rev 2179)
@@ -25,20 +25,20 @@
if getattr(self, column) != getattr(next, column):
fields.append(column.title())
- return fields
+ return fields
- @classmethod
def select(cls, clause=None, *args, **kw):
if not getattr(cls, '_connection', None):
- cls._connection = cls.masterClass._connection
+ cls._connection = cls.masterClass._connection
return super(Version, cls).select(clause, *args, **kw)
+ select = classmethod(select)
def getColumns(columns, cls):
for column, defi in cls.sqlmeta.columnDefinitions.items():
if column.endswith("ID") and isinstance(defi, ForeignKey):
column = column[:-2]
columns[column] = defi.__class__(**defi._kw)
-
+
#ascend heirarchy
if cls.sqlmeta.parentClass:
getColumns(columns, cls.sqlmeta.parentClass)
@@ -52,13 +52,13 @@
self.name = name
self.soClass = soClass
- attrs = {'dateArchived': DateTimeCol(default=datetime.now),
+ attrs = {'dateArchived': DateTimeCol(default=datetime.now),
'master': ForeignKey(self.soClass.__name__),
'masterClass' : self.soClass,
}
-
+
getColumns (attrs, self.soClass)
-
+
self.versionClass = type(self.soClass.__name__+'Versions',
(Version,),
attrs)
Modified: SQLObject/trunk/sqlobject/versioning/test/test_version.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-08 21:32:46 UTC (rev 2178)
+++ SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-09 16:14:09 UTC (rev 2179)
@@ -1,8 +1,9 @@
from py.test import raises
from sqlobject import *
-from sqlobject.tests.dbtest import *
+from sqlobject.events import sorted
from sqlobject.inheritance import InheritableSQLObject
from sqlobject.versioning import Versioning
+from sqlobject.tests.dbtest import *
from datetime import datetime
|
|
From: <sub...@co...> - 2007-01-08 21:32:59
|
Author: novalis
Date: 2007-01-08 14:32:46 -0700 (Mon, 08 Jan 2007)
New Revision: 2178
Modified:
SQLObject/trunk/sqlobject/main.py
SQLObject/trunk/sqlobject/versioning/__init__.py
SQLObject/trunk/sqlobject/versioning/test/test_version.py
Log:
now versioning works outside of tests
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2007-01-08 19:22:26 UTC (rev 2177)
+++ SQLObject/trunk/sqlobject/main.py 2007-01-08 21:32:46 UTC (rev 2178)
@@ -787,10 +787,6 @@
if connection and not hasattr(cls, '_connection'):
cls.setConnection(connection)
- # Now the class is in an essentially OK-state, so we can
- # set up any magic attributes:
- declarative.setup_attributes(cls, new_attrs)
-
# We have to check if there are columns in the inherited
# _columns where the attribute has been set to None in this
# class. If so, then we need to remove that column from
@@ -806,6 +802,10 @@
for column in implicitColumns:
cls.sqlmeta.addColumn(column)
+ # Now the class is in an essentially OK-state, so we can
+ # set up any magic attributes:
+ declarative.setup_attributes(cls, new_attrs)
+
if cls.sqlmeta.fromDatabase:
cls.sqlmeta.addColumnsFromDatabase()
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-08 19:22:26 UTC (rev 2177)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-08 21:32:46 UTC (rev 2178)
@@ -27,6 +27,12 @@
return fields
+ @classmethod
+ def select(cls, clause=None, *args, **kw):
+ if not getattr(cls, '_connection', None):
+ cls._connection = cls.masterClass._connection
+ return super(Version, cls).select(clause, *args, **kw)
+
def getColumns(columns, cls):
for column, defi in cls.sqlmeta.columnDefinitions.items():
if column.endswith("ID") and isinstance(defi, ForeignKey):
@@ -45,27 +51,25 @@
def __addtoclass__(self, soClass, name):
self.name = name
self.soClass = soClass
- self.versionClass = None
- events.listen(self.createTable,
- soClass, events.CreateTableSignal)
- events.listen(self.rowUpdate, soClass,
- events.RowUpdateSignal)
- def createVersionTable(self, cls, conn):
attrs = {'dateArchived': DateTimeCol(default=datetime.now),
'master': ForeignKey(self.soClass.__name__),
'masterClass' : self.soClass,
- '_connection' : conn,
}
-
+
getColumns (attrs, self.soClass)
+
+ self.versionClass = type(self.soClass.__name__+'Versions',
+ (Version,),
+ attrs)
- if not self.versionClass:
- self.versionClass = type(self.soClass.__name__+'Versions',
- (Version,),
- attrs)
+ events.listen(self.createTable,
+ soClass, events.CreateTableSignal)
+ events.listen(self.rowUpdate, soClass,
+ events.RowUpdateSignal)
- self.versionClass.createTable(ifNotExists=True, connection=conn)
+ def createVersionTable(self, cls, conn):
+ self.versionClass.createTable(ifNotExists=True, connection=conn)
def createTable(self, soClass, connection, extra_sql, post_funcs):
assert soClass is self.soClass
Modified: SQLObject/trunk/sqlobject/versioning/test/test_version.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-08 19:22:26 UTC (rev 2177)
+++ SQLObject/trunk/sqlobject/versioning/test/test_version.py 2007-01-08 21:32:46 UTC (rev 2178)
@@ -11,6 +11,7 @@
for cls in [MyClass, Base, Child, Government, Monarchy, VChild, HasForeign]:
setupClass(cls)
if hasattr(cls, 'versions'):
+ setupClass(cls.versions.versionClass)
for version in cls.versions.versionClass.select():
version.destroySelf()
|
|
From: <sub...@co...> - 2007-01-08 17:11:32
|
Author: novalis
Date: 2007-01-08 10:11:21 -0700 (Mon, 08 Jan 2007)
New Revision: 2176
Modified:
SQLObject/trunk/sqlobject/versioning/__init__.py
Log:
gee, that was a dumb way to add methods to a class
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-04 20:40:02 UTC (rev 2175)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-08 17:11:21 UTC (rev 2176)
@@ -9,6 +9,24 @@
del values['dateArchived']
self.masterClass.get(self.masterID).set(**values)
+ def nextVersion(self):
+ version = self.select(AND(self.q.masterID == self.masterID, self.q.id > self.id), limit=1, orderBy=self.q.id)
+ if version.count():
+ return version[0]
+ else:
+ return self.master
+
+ def getChangedFields(self):
+ next = self.nextVersion()
+ columns = self.__class__.sqlmeta.columns
+ fields = []
+ for column in columns:
+ if column not in ["dateArchived", "id", "masterID"]:
+ if getattr(self, column) != getattr(next, column):
+ fields.append(column.title())
+
+ return fields
+
def getColumns(columns, cls):
for column, defi in cls.sqlmeta.columnDefinitions.items():
if column.endswith("ID") and isinstance(defi, ForeignKey):
@@ -19,25 +37,7 @@
if cls.sqlmeta.parentClass:
getColumns(columns, cls.sqlmeta.parentClass)
-#these two are methods for a versionable object
-def _nextVersion(self):
- version = self.select(AND(self.q.masterID == self.masterID, self.q.id > self.id), limit=1, orderBy=self.q.id)
- if version.count():
- return version[0]
- else:
- return self.master
-def _getChangedFields(self):
- next = self.nextVersion()
- columns = self.__class__.sqlmeta.columns
- fields = []
- for column in columns:
- if column not in ["dateArchived", "id", "masterID"]:
- if getattr(self, column) != getattr(next, column):
- fields.append(column.title())
-
- return fields
-
class Versioning(object):
def __init__(self):
pass
@@ -55,8 +55,6 @@
attrs = {'dateArchived': DateTimeCol(default=datetime.now),
'master': ForeignKey(self.soClass.__name__),
'masterClass' : self.soClass,
- 'nextVersion' : _nextVersion,
- 'getChangedFields' : _getChangedFields,
'_connection' : conn,
}
|
|
From: SourceForge.net <no...@so...> - 2007-01-08 10:49:50
|
Patches item #1630441, was opened at 2007-01-08 13:39 Message generated for change (Comment added) made by mgfox You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1630441&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: Mike Vorozhbensky (mgfox) Assigned to: Nobody/Anonymous (nobody) Summary: revision 2150 firebird connectionFromURI *NIX db alias usage Initial Comment: when i try to use URI like "firebird://localhost/database" (database - database alias) in linux, i see error: --- cut --- File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/sresults.py", line 160, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/sresults.py", line 168, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/dbconnection.py", line 373, in iterSelect return select.IterationClass(self, self.getConnection(), File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/dbconnection.py", line 239, in getConnection conn = self.makeConnection() File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/firebird/firebirdconnection.py", line 87, in makeConnection charset=self.charset, File "/var/lib/python-support/python2.4/kinterbasdb/__init__.py", line 472, in connect return Connection(*args, **keywords_args) File "/var/lib/python-support/python2.4/kinterbasdb/__init__.py", line 610, in __init__ self._C_con = _k.attach_db(dsn, dpb, dialect) OperationalError: (-902, 'isc_attach_database: I/O error for file "/database". Error while trying to open file. No such file or directory. ') --- end cut --- path fix this problem ---------------------------------------------------------------------- >Comment By: Mike Vorozhbensky (mgfox) Date: 2007-01-08 13:49 Message: Logged In: YES user_id=1240394 Originator: YES bug also present in revision 2175 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1630441&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-08 10:39:25
|
Patches item #1630441, was opened at 2007-01-08 13:39 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1630441&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: Mike Vorozhbensky (mgfox) Assigned to: Nobody/Anonymous (nobody) Summary: revision 2150 firebird connectionFromURI *NIX db alias usage Initial Comment: when i try to use URI like "firebird://localhost/database" (database - database alias) in linux, i see error: --- cut --- File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/sresults.py", line 160, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/sresults.py", line 168, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/dbconnection.py", line 373, in iterSelect return select.IterationClass(self, self.getConnection(), File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/dbconnection.py", line 239, in getConnection conn = self.makeConnection() File "/usr/lib/python2.4/site-packages/SQLObject-0.9dev_r2147-py2.4.egg/sqlobject/firebird/firebirdconnection.py", line 87, in makeConnection charset=self.charset, File "/var/lib/python-support/python2.4/kinterbasdb/__init__.py", line 472, in connect return Connection(*args, **keywords_args) File "/var/lib/python-support/python2.4/kinterbasdb/__init__.py", line 610, in __init__ self._C_con = _k.attach_db(dsn, dpb, dialect) OperationalError: (-902, 'isc_attach_database: I/O error for file "/database". Error while trying to open file. No such file or directory. ') --- end cut --- path fix this problem ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1630441&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2007-01-05 16:19:00
|
Bugs item #1628893, was opened at 2007-01-05 17:18 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1628893&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: Postgres Group: SQLObject release (specify) Status: Open Resolution: None Priority: 5 Private: No Submitted By: Laurent DAVERIO (ldaverio) Assigned to: Nobody/Anonymous (nobody) Summary: SQLObject 0.7.2 / Zope / Pg DateTimeCol problem Initial Comment: When upgrading from version 0.7.0 to 0.7.2, SQLObject used inside Zope becomes unable to access PostgreSQL timestamp columns. If a column has type "timestamp" or "timestamp with time zone" or "timestamp without time zone", it will be represented as a DateTimeCol in SQLObject. The traceback below is obtained when trying to acess data from a table having such a timestamp column : Module Products.Outdoor.Classes, line 1311, in getEchantillonTemoignages Module sqlobject.sresults, line 155, in __iter__ Module sqlobject.dbconnection, line 721, in next Module sqlobject.main, line 918, in get Module sqlobject.main, line 964, in _init Module sqlobject.main, line 1155, in _SO_selectInit Module sqlobject.col, line 955, in to_python Invalid: expected an date/time string of the '%Y-%m-%d %H:%M:%S' format in the DateTimeCol 'dateTemoig nage', got <type 'instance'> DateTime('2006/12/13 11:41:40 GMT+0') instead The error is the same regardless of whether the schema is defined explicitly in Python, or not (i.e. fromDatabase=True in the sqlmeta class). The exact same fragment of code will work flawlessly from a Python script, or event from Zope's debug shell. It seems that Zope's DateTime implementation automatically appends timezone information to the string representation of the timestamp value. A partial workaround would be to change the type of the column to 'text', but then it would no longer possible to perform date calculations on the value, or to use strftime formatting. The release notes of SQLObject 0.7.2 indicate that some of the changes were specifically intended to make SQLObject compatible with Zope, but unfortunately the result seems to be exactly opposite... My setup : - FreeBSD 6.1 - Python 2.4.3 - Zope 2.9.6 - SQLObject 0.7.2 - PostgreSQL 8.1.5 (all software installed from FreeBSD Ports) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1628893&group_id=74338 |
|
From: <sub...@co...> - 2007-01-04 20:40:13
|
Author: novalis
Date: 2007-01-04 13:40:02 -0700 (Thu, 04 Jan 2007)
New Revision: 2175
Modified:
SQLObject/trunk/sqlobject/versioning/__init__.py
Log:
do not recreate version class
Modified: SQLObject/trunk/sqlobject/versioning/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-04 20:39:49 UTC (rev 2174)
+++ SQLObject/trunk/sqlobject/versioning/__init__.py 2007-01-04 20:40:02 UTC (rev 2175)
@@ -62,11 +62,12 @@
getColumns (attrs, self.soClass)
- self.versionClass = type(self.soClass.__name__+'Versions',
- (Version,),
- attrs)
+ if not self.versionClass:
+ self.versionClass = type(self.soClass.__name__+'Versions',
+ (Version,),
+ attrs)
- self.versionClass.createTable(connection=conn)
+ self.versionClass.createTable(ifNotExists=True, connection=conn)
def createTable(self, soClass, connection, extra_sql, post_funcs):
assert soClass is self.soClass
|