sqlobject-cvs Mailing List for SQLObject (Page 142)
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...> - 2006-01-24 09:20:21
|
Bugs item #1334786, was opened at 2005-10-22 11:30 Message generated for change (Comment added) made by dpinte You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1334786&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 Submitted By: M. Dietrich (mdt) Assigned to: Nobody/Anonymous (nobody) Summary: infinitiv recursion in Transaction.__del__ Initial Comment: using ThreadConnections i get a Exception exceptions.RuntimeError: 'maximum recursion depth exceeded' in <bound method Transaction.__del__ of <sqlobject.dbconnection.Transaction object at 0xaedb714c>> ignored , commenting __del__() works in the first place. can't figure out what this __del__ is for... ---------------------------------------------------------------------- Comment By: Didrik Pinte (dpinte) Date: 2006-01-24 10:20 Message: Logged In: YES user_id=970259 Same here, I can reproduce it. It happens when the database is not started. Here is a test code : Step 1 : Shut down you postgres server Step 2 : Run the following ------------------------- import sqlobject scheme = "postgres://myusername:mypassword@localhost/mydb" connection = sqlobject.connectionForURI(scheme) sqlobject.sqlhub.processConnection = connection sqlhub.threadConnection = connection.transaction() -------------------------- Didrik ---------------------------------------------------------------------- Comment By: xiao hai tong (haitong) Date: 2005-12-04 18:35 Message: Logged In: YES user_id=146934 I encount it too. once is too many connection crash my pgsql server on windows, then may of such exceptions reported. other time: a multi thread test program. I want to retry my transaction when excecption occured during commit, I commet the threadConnection.rollback(), just set threadConnection = g_conn.transaction(), and redo the transaction after seconds, such exceptions occurred. ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-10-25 18:12 Message: Logged In: YES user_id=4799 Can you make a little test program that demonstrates the problem? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1334786&group_id=74338 |
|
From: <sub...@co...> - 2006-01-23 17:08:11
|
Author: phd
Date: 2006-01-23 08:35:50 -0700 (Mon, 23 Jan 2006)
New Revision: 1534
Added:
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_foreignKey.py
Removed:
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_selectBy_foreignKey.py
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/col.py
SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
Log:
Renamed test_selectBy_foreignKey.py to test_foreignKey.py.
Added a test for addColumn().
Added ForeignKey.postgresCreateColumnSQL(); this is a quick and dirty fix
for ALTER TABLE ADD CONSTRAINT, implemented only for 0.7-branch; 0.8 (trunk)
implements this in a much cleaner way.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/col.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/col.py 2006-01-23 15:33:18 UTC (rev 1533)
+++ SQLObject/branches/0.7-bugfix/sqlobject/col.py 2006-01-23 15:35:50 UTC (rev 1534)
@@ -757,6 +757,30 @@
sql = ', '.join([sql, constraint])
return sql
+ def postgresCreateColumnSQL(self):
+ sql = SOKeyCol.postgresCreateSQL(self)
+ other = findClass(self.foreignKey, self.soClass.sqlmeta.registry)
+ tName = other.sqlmeta.table
+ idName = other.sqlmeta.idName
+ if self.cascade is not None:
+ if self.cascade == 'null':
+ action = 'ON DELETE SET NULL'
+ elif self.cascade:
+ action = 'ON DELETE CASCADE'
+ else:
+ action = 'ON DELETE RESTRICT'
+ else:
+ action = ''
+ constraint = ('CONSTRAINT %(colName)s_exists '
+ 'REFERENCES %(tName)s (%(idName)s) '
+ '%(action)s' %
+ {'tName': tName,
+ 'colName': self.dbName,
+ 'idName': idName,
+ 'action': action})
+ sql = ' '.join([sql, constraint])
+ return sql
+
def sybaseCreateSQL(self):
sql = SOKeyCol.sybaseCreateSQL(self)
other = findClass(self.foreignKey)
Modified: SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2006-01-23 15:33:18 UTC (rev 1533)
+++ SQLObject/branches/0.7-bugfix/sqlobject/postgres/pgconnection.py 2006-01-23 15:35:50 UTC (rev 1534)
@@ -162,9 +162,13 @@
return result[0]
def addColumn(self, tableName, column):
+ if hasattr(column, "postgresCreateColumnSQL"):
+ postgresCreateSQL = column.postgresCreateColumnSQL
+ else:
+ postgresCreateSQL = column.postgresCreateSQL
self.query('ALTER TABLE %s ADD COLUMN %s' %
(tableName,
- column.postgresCreateSQL()))
+ postgresCreateSQL()))
def delColumn(self, tableName, column):
self.query('ALTER TABLE %s DROP COLUMN %s' %
Copied: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_foreignKey.py (from rev 1530, SQLObject/branches/0.7-bugfix/sqlobject/tests/test_selectBy_foreignKey.py)
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 12:56:29 UTC (rev 1530)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_foreignKey.py 2006-01-23 15:35:50 UTC (rev 1534)
@@ -0,0 +1,40 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+
+class TestComposerKey(SQLObject):
+ name = StringCol()
+
+class TestWorkKey(SQLObject):
+ class sqlmeta:
+ idName = "work_id"
+
+ composer = ForeignKey('TestComposerKey', cascade=True)
+ title = StringCol()
+
+class TestWorkKey2(SQLObject):
+ title = StringCol()
+
+def test1():
+ setupClass([TestComposerKey,
+ TestWorkKey])
+
+ c = TestComposerKey(name='Mahler, Gustav')
+ w1 = TestWorkKey(composer=c, title='Symphony No. 9')
+ w2 = TestWorkKey(composer=None, title=None)
+
+ # Select by usual way
+ s = TestWorkKey.selectBy(composerID=c.id, title='Symphony No. 9')
+ assert s[0]==w1
+ # selectBy object
+ s = TestWorkKey.selectBy(composer=c, title='Symphony No. 9')
+ assert s[0]==w1
+ # selectBy id
+ s = TestWorkKey.selectBy(id=w1.id)
+ assert s[0]==w1
+ # is None handled correctly?
+ s = TestWorkKey.selectBy(composer=None, title=None)
+ assert s[0]==w2
+
+def test2():
+ setupClass([TestComposerKey, TestWorkKey2])
+ TestWorkKey2.sqlmeta.addColumn(ForeignKey('TestComposerKey'), changeSchema=True)
Deleted: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_selectBy_foreignKey.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 15:33:18 UTC (rev 1533)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 15:35:50 UTC (rev 1534)
@@ -1,33 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-
-class TestComposerKey(SQLObject):
- name = StringCol()
-
-class TestWorkKey(SQLObject):
- class sqlmeta:
- idName = "work_id"
-
- composer = ForeignKey('TestComposerKey')
- title = StringCol()
-
-def test1():
- setupClass([TestComposerKey,
- TestWorkKey])
-
- c = TestComposerKey(name='Mahler, Gustav')
- w1 = TestWorkKey(composer=c, title='Symphony No. 9')
- w2 = TestWorkKey(composer=None, title=None)
-
- # Select by usual way
- s = TestWorkKey.selectBy(composerID=c.id, title='Symphony No. 9')
- assert s[0]==w1
- # selectBy object
- s = TestWorkKey.selectBy(composer=c, title='Symphony No. 9')
- assert s[0]==w1
- # selectBy id
- s = TestWorkKey.selectBy(id=w1.id)
- assert s[0]==w1
- # is None handled correctly?
- s = TestWorkKey.selectBy(composer=None, title=None)
- assert s[0]==w2
|
|
From: <sub...@co...> - 2006-01-23 17:08:09
|
Author: phd
Date: 2006-01-23 08:33:18 -0700 (Mon, 23 Jan 2006)
New Revision: 1533
Added:
home/phd/SQLObject/paramstyles/sqlobject/tests/test_foreignKey.py
Removed:
home/phd/SQLObject/paramstyles/sqlobject/tests/test_selectBy_foreignKey.py
Log:
Merged patches from the revisions 1531:1532 from the trunk
Copied: home/phd/SQLObject/paramstyles/sqlobject/tests/test_foreignKey.py (from rev 1532, SQLObject/trunk/sqlobject/tests/test_foreignKey.py)
Deleted: home/phd/SQLObject/paramstyles/sqlobject/tests/test_selectBy_foreignKey.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 15:32:28 UTC (rev 1532)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 15:33:18 UTC (rev 1533)
@@ -1,33 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-
-class TestComposerKey(SQLObject):
- name = StringCol()
-
-class TestWorkKey(SQLObject):
- class sqlmeta:
- idName = "work_id"
-
- composer = ForeignKey('TestComposerKey')
- title = StringCol()
-
-def test1():
- setupClass([TestComposerKey,
- TestWorkKey])
-
- c = TestComposerKey(name='Mahler, Gustav')
- w1 = TestWorkKey(composer=c, title='Symphony No. 9')
- w2 = TestWorkKey(composer=None, title=None)
-
- # Select by usual way
- s = TestWorkKey.selectBy(composerID=c.id, title='Symphony No. 9')
- assert s[0]==w1
- # selectBy object
- s = TestWorkKey.selectBy(composer=c, title='Symphony No. 9')
- assert s[0]==w1
- # selectBy id
- s = TestWorkKey.selectBy(id=w1.id)
- assert s[0]==w1
- # is None handled correctly?
- s = TestWorkKey.selectBy(composer=None, title=None)
- assert s[0]==w2
|
|
From: <sub...@co...> - 2006-01-23 17:08:08
|
Author: phd
Date: 2006-01-23 08:32:28 -0700 (Mon, 23 Jan 2006)
New Revision: 1532
Added:
SQLObject/trunk/sqlobject/tests/test_foreignKey.py
Removed:
SQLObject/trunk/sqlobject/tests/test_selectBy_foreignKey.py
Log:
Renamed test_selectBy_foreignKey.py to test_foreignKey.py.
Added a test for addColumn().
Copied: SQLObject/trunk/sqlobject/tests/test_foreignKey.py (from rev 1530, SQLObject/trunk/sqlobject/tests/test_selectBy_foreignKey.py)
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 12:56:29 UTC (rev 1530)
+++ SQLObject/trunk/sqlobject/tests/test_foreignKey.py 2006-01-23 15:32:28 UTC (rev 1532)
@@ -0,0 +1,39 @@
+from sqlobject import *
+from sqlobject.tests.dbtest import *
+
+class TestComposerKey(SQLObject):
+ name = StringCol()
+
+class TestWorkKey(SQLObject):
+ class sqlmeta:
+ idName = "work_id"
+
+ composer = ForeignKey('TestComposerKey', cascade=True)
+ title = StringCol()
+
+class TestWorkKey2(SQLObject):
+ title = StringCol()
+
+def test1():
+ setupClass([TestComposerKey, TestWorkKey])
+
+ c = TestComposerKey(name='Mahler, Gustav')
+ w1 = TestWorkKey(composer=c, title='Symphony No. 9')
+ w2 = TestWorkKey(composer=None, title=None)
+
+ # Select by usual way
+ s = TestWorkKey.selectBy(composerID=c.id, title='Symphony No. 9')
+ assert s[0]==w1
+ # selectBy object
+ s = TestWorkKey.selectBy(composer=c, title='Symphony No. 9')
+ assert s[0]==w1
+ # selectBy id
+ s = TestWorkKey.selectBy(id=w1.id)
+ assert s[0]==w1
+ # is None handled correctly?
+ s = TestWorkKey.selectBy(composer=None, title=None)
+ assert s[0]==w2
+
+def test2():
+ setupClass([TestComposerKey, TestWorkKey2])
+ TestWorkKey2.sqlmeta.addColumn(ForeignKey('TestComposerKey'), changeSchema=True)
Deleted: SQLObject/trunk/sqlobject/tests/test_selectBy_foreignKey.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 13:32:08 UTC (rev 1531)
+++ SQLObject/trunk/sqlobject/tests/test_selectBy_foreignKey.py 2006-01-23 15:32:28 UTC (rev 1532)
@@ -1,33 +0,0 @@
-from sqlobject import *
-from sqlobject.tests.dbtest import *
-
-class TestComposerKey(SQLObject):
- name = StringCol()
-
-class TestWorkKey(SQLObject):
- class sqlmeta:
- idName = "work_id"
-
- composer = ForeignKey('TestComposerKey')
- title = StringCol()
-
-def test1():
- setupClass([TestComposerKey,
- TestWorkKey])
-
- c = TestComposerKey(name='Mahler, Gustav')
- w1 = TestWorkKey(composer=c, title='Symphony No. 9')
- w2 = TestWorkKey(composer=None, title=None)
-
- # Select by usual way
- s = TestWorkKey.selectBy(composerID=c.id, title='Symphony No. 9')
- assert s[0]==w1
- # selectBy object
- s = TestWorkKey.selectBy(composer=c, title='Symphony No. 9')
- assert s[0]==w1
- # selectBy id
- s = TestWorkKey.selectBy(id=w1.id)
- assert s[0]==w1
- # is None handled correctly?
- s = TestWorkKey.selectBy(composer=None, title=None)
- assert s[0]==w2
|
|
From: <sub...@co...> - 2006-01-23 13:32:17
|
Author: phd
Date: 2006-01-23 06:32:08 -0700 (Mon, 23 Jan 2006)
New Revision: 1531
Modified:
home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto_old.py
Log:
Merged patches from the revisions 1528:1530 from the trunk: implemented addColumn() for SQLite.
Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-01-23 12:56:29 UTC (rev 1530)
+++ home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-01-23 13:32:08 UTC (rev 1531)
@@ -202,5 +202,13 @@
def createIndexSQL(self, soClass, index):
return index.sqliteCreateIndexSQL(soClass)
+ def addColumn(self, tableName, column):
+ self.query('ALTER TABLE %s ADD COLUMN %s' %
+ (tableName,
+ column.sqliteCreateSQL()))
+
+ def delColumn(self, tableName, column):
+ pass # Oops! There is no DROP COLUMN in SQLite
+
def stop_pysqlite2_converting_strings_to_unicode(s):
return s
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py 2006-01-23 12:56:29 UTC (rev 1530)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/dbtest.py 2006-01-23 13:32:08 UTC (rev 1531)
@@ -35,7 +35,6 @@
'+restrictedEnum': 'postgres',
'-transactions': 'mysql',
'-dropTableCascade': 'sybase mssql',
- '-dynamicColumn': 'sqlite sybase',
'-fromDatabase': 'sqlite sybase firebird',
'-expressionIndex': 'mysql sqlite firebird mssql',
'-blobData': 'mssql',
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto.py 2006-01-23 12:56:29 UTC (rev 1530)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto.py 2006-01-23 13:32:08 UTC (rev 1531)
@@ -39,8 +39,6 @@
list(Person.select('all', orderBy=Person.sqlmeta.defaultOrder)))
def test_dynamicColumn(self):
- if not supports('dynamicColumn'):
- return
nickname = StringCol('nickname', length=10)
Person.sqlmeta.addColumn(nickname, changeSchema=True)
n = Person(name='robert', nickname='bob')
@@ -49,8 +47,6 @@
Person.sqlmeta.delColumn(nickname, changeSchema=True)
def test_dynamicJoin(self):
- if not supports('dynamicColumn'):
- return
col = KeyCol('personID', foreignKey='Person')
Phone.sqlmeta.addColumn(col, changeSchema=True)
join = MultipleJoin('Phone')
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto_old.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto_old.py 2006-01-23 12:56:29 UTC (rev 1530)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_auto_old.py 2006-01-23 13:32:08 UTC (rev 1531)
@@ -41,8 +41,6 @@
list(OldPerson.select('all', orderBy=OldPerson.sqlmeta.defaultOrder)))
def test_dynamicColumn(self):
- if not supports('dynamicColumn'):
- return
nickname = StringCol('nickname', length=10)
OldPerson.addColumn(nickname, changeSchema=True)
n = OldPerson(name='robert', nickname='bob')
@@ -51,8 +49,6 @@
OldPerson.delColumn(nickname, changeSchema=True)
def test_dynamicJoin(self):
- if not supports('dynamicColumn'):
- return
col = KeyCol('oldPersonID', foreignKey='OldPerson')
OldPhone.addColumn(col, changeSchema=True)
join = MultipleJoin('OldPhone')
|
|
From: <sub...@co...> - 2006-01-23 12:56:35
|
Author: phd
Date: 2006-01-23 05:56:29 -0700 (Mon, 23 Jan 2006)
New Revision: 1530
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto_old.py
Log:
Merged a patch from the rev 1529 from the trunk: implemented addColumn() for SQLite.
Modified: SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-01-23 12:55:29 UTC (rev 1529)
+++ SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-01-23 12:56:29 UTC (rev 1530)
@@ -198,5 +198,13 @@
def createIndexSQL(self, soClass, index):
return index.sqliteCreateIndexSQL(soClass)
+ def addColumn(self, tableName, column):
+ self.query('ALTER TABLE %s ADD COLUMN %s' %
+ (tableName,
+ column.sqliteCreateSQL()))
+
+ def delColumn(self, tableName, column):
+ pass # Oops! There is no DROP COLUMN in SQLite
+
def stop_pysqlite2_converting_strings_to_unicode(s):
return s
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py 2006-01-23 12:55:29 UTC (rev 1529)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/dbtest.py 2006-01-23 12:56:29 UTC (rev 1530)
@@ -35,7 +35,6 @@
'+restrictedEnum': 'postgres',
'-transactions': 'mysql',
'-dropTableCascade': 'sybase mssql',
- '-dynamicColumn': 'sqlite sybase',
'-fromDatabase': 'sqlite sybase firebird',
'-expressionIndex': 'mysql sqlite firebird mssql',
'-blobData': 'mssql',
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py 2006-01-23 12:55:29 UTC (rev 1529)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto.py 2006-01-23 12:56:29 UTC (rev 1530)
@@ -39,8 +39,6 @@
list(Person.select('all', orderBy=Person.sqlmeta.defaultOrder)))
def test_dynamicColumn(self):
- if not supports('dynamicColumn'):
- return
nickname = StringCol('nickname', length=10)
Person.sqlmeta.addColumn(nickname, changeSchema=True)
n = Person(name='robert', nickname='bob')
@@ -49,8 +47,6 @@
Person.sqlmeta.delColumn(nickname, changeSchema=True)
def test_dynamicJoin(self):
- if not supports('dynamicColumn'):
- return
col = KeyCol('personID', foreignKey='Person')
Phone.sqlmeta.addColumn(col, changeSchema=True)
join = MultipleJoin('Phone')
Modified: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto_old.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto_old.py 2006-01-23 12:55:29 UTC (rev 1529)
+++ SQLObject/branches/0.7-bugfix/sqlobject/tests/test_auto_old.py 2006-01-23 12:56:29 UTC (rev 1530)
@@ -41,8 +41,6 @@
list(OldPerson.select('all', orderBy=OldPerson.sqlmeta.defaultOrder)))
def test_dynamicColumn(self):
- if not supports('dynamicColumn'):
- return
nickname = StringCol('nickname', length=10)
OldPerson.addColumn(nickname, changeSchema=True)
n = OldPerson(name='robert', nickname='bob')
@@ -51,8 +49,6 @@
OldPerson.delColumn(nickname, changeSchema=True)
def test_dynamicJoin(self):
- if not supports('dynamicColumn'):
- return
col = KeyCol('oldPersonID', foreignKey='OldPerson')
OldPhone.addColumn(col, changeSchema=True)
join = MultipleJoin('OldPhone')
|
|
From: <sub...@co...> - 2006-01-23 12:55:37
|
Author: phd
Date: 2006-01-23 05:55:29 -0700 (Mon, 23 Jan 2006)
New Revision: 1529
Modified:
SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
SQLObject/trunk/sqlobject/tests/dbtest.py
SQLObject/trunk/sqlobject/tests/test_auto.py
SQLObject/trunk/sqlobject/tests/test_auto_old.py
Log:
Implemented addColumn() for SQLite. Added empty delColumn() for tests.
Modified: SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-01-23 07:53:24 UTC (rev 1528)
+++ SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-01-23 12:55:29 UTC (rev 1529)
@@ -202,5 +202,13 @@
def createIndexSQL(self, soClass, index):
return index.sqliteCreateIndexSQL(soClass)
+ def addColumn(self, tableName, column):
+ self.query('ALTER TABLE %s ADD COLUMN %s' %
+ (tableName,
+ column.sqliteCreateSQL()))
+
+ def delColumn(self, tableName, column):
+ pass # Oops! There is no DROP COLUMN in SQLite
+
def stop_pysqlite2_converting_strings_to_unicode(s):
return s
Modified: SQLObject/trunk/sqlobject/tests/dbtest.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/dbtest.py 2006-01-23 07:53:24 UTC (rev 1528)
+++ SQLObject/trunk/sqlobject/tests/dbtest.py 2006-01-23 12:55:29 UTC (rev 1529)
@@ -35,7 +35,6 @@
'+restrictedEnum': 'postgres',
'-transactions': 'mysql',
'-dropTableCascade': 'sybase mssql',
- '-dynamicColumn': 'sqlite sybase',
'-fromDatabase': 'sqlite sybase firebird',
'-expressionIndex': 'mysql sqlite firebird mssql',
'-blobData': 'mssql',
Modified: SQLObject/trunk/sqlobject/tests/test_auto.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_auto.py 2006-01-23 07:53:24 UTC (rev 1528)
+++ SQLObject/trunk/sqlobject/tests/test_auto.py 2006-01-23 12:55:29 UTC (rev 1529)
@@ -39,8 +39,6 @@
list(Person.select('all', orderBy=Person.sqlmeta.defaultOrder)))
def test_dynamicColumn(self):
- if not supports('dynamicColumn'):
- return
nickname = StringCol('nickname', length=10)
Person.sqlmeta.addColumn(nickname, changeSchema=True)
n = Person(name='robert', nickname='bob')
@@ -49,8 +47,6 @@
Person.sqlmeta.delColumn(nickname, changeSchema=True)
def test_dynamicJoin(self):
- if not supports('dynamicColumn'):
- return
col = KeyCol('personID', foreignKey='Person')
Phone.sqlmeta.addColumn(col, changeSchema=True)
join = MultipleJoin('Phone')
Modified: SQLObject/trunk/sqlobject/tests/test_auto_old.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_auto_old.py 2006-01-23 07:53:24 UTC (rev 1528)
+++ SQLObject/trunk/sqlobject/tests/test_auto_old.py 2006-01-23 12:55:29 UTC (rev 1529)
@@ -41,8 +41,6 @@
list(OldPerson.select('all', orderBy=OldPerson.sqlmeta.defaultOrder)))
def test_dynamicColumn(self):
- if not supports('dynamicColumn'):
- return
nickname = StringCol('nickname', length=10)
OldPerson.addColumn(nickname, changeSchema=True)
n = OldPerson(name='robert', nickname='bob')
@@ -51,8 +49,6 @@
OldPerson.delColumn(nickname, changeSchema=True)
def test_dynamicJoin(self):
- if not supports('dynamicColumn'):
- return
col = KeyCol('oldPersonID', foreignKey='OldPerson')
OldPhone.addColumn(col, changeSchema=True)
join = MultipleJoin('OldPhone')
|
|
From: <sub...@co...> - 2006-01-23 07:53:32
|
Author: phd
Date: 2006-01-23 00:53:24 -0700 (Mon, 23 Jan 2006)
New Revision: 1528
Added:
home/phd/SQLObject/paramstyles/sqlobject/tests/test_sqlite_threaded.py
Modified:
home/phd/SQLObject/paramstyles/sqlobject/col.py
home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_paste.py
Log:
Merged patches from the revisions 1517:1527 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/col.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-01-23 06:02:07 UTC (rev 1527)
+++ home/phd/SQLObject/paramstyles/sqlobject/col.py 2006-01-23 07:53:24 UTC (rev 1528)
@@ -1153,8 +1153,8 @@
try:
return Decimal(value)
except:
- raise validators.Invalid("can not parse Decimal value '%s' in the DecimalCol '%s'" %
- (value, self.name), value, state)
+ raise validators.Invalid("can not parse Decimal value '%s' in the DecimalCol from '%s'" %
+ (value, getattr(state, 'soObject', '(unknown)')), value, state)
if not isinstance(value, (int, long, Decimal, sqlbuilder.SQLExpression)):
raise validators.Invalid("expected a decimal in the DecimalCol '%s', got %s %r instead" % \
(self.name, type(value), value), value, state)
Modified: home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-01-23 06:02:07 UTC (rev 1527)
+++ home/phd/SQLObject/paramstyles/sqlobject/sqlite/sqliteconnection.py 2006-01-23 07:53:24 UTC (rev 1528)
@@ -1,5 +1,6 @@
from sqlobject.dbconnection import DBAPI
from sqlobject.col import popKey
+import thread
sqlite = None
using_sqlite2 = False
@@ -23,6 +24,12 @@
using_sqlite2 = False
self.module = sqlite
self.filename = filename # full path to sqlite-db-file
+ self._memory = filename == ':memory:'
+ if self._memory:
+ if not using_sqlite2:
+ raise ValueError(
+ "You must use sqlite2 to use in-memory databases")
+ #kw.setdefault('check_same_thread', False)
# connection options
opts = {}
if using_sqlite2:
@@ -58,8 +65,13 @@
opts['timeout'] = float(popKey(kw, 'timeout'))
# use only one connection for sqlite - supports multiple)
# cursors per connection
- self._conn = sqlite.connect(self.filename, **opts)
+ self._connOptions = opts
DBAPI.__init__(self, **kw)
+ self._threadPool = {}
+ self._threadOrigination = {}
+ if self._memory:
+ self._memoryConn = sqlite.connect(
+ self.filename, **self._connOptions)
def connectionFromURI(cls, uri):
user, password, host, port, path, args = cls._parseURI(uri)
@@ -69,13 +81,53 @@
assert user is None and password is None, (
"You may not provide usernames or passwords for SQLite "
"databases")
- if path == "/:memory:": path = ":memory:"
+ if path == "/:memory:":
+ path = ":memory:"
return cls(filename=path, **args)
connectionFromURI = classmethod(connectionFromURI)
def uri(self):
return 'sqlite:///%s' % self.filename
+ def getConnection(self):
+ # SQLite can't share connections between threads, and so can't
+ # pool connections. Since we are isolating threads here, we
+ # don't have to worry about locking as much.
+ if self._memory:
+ return self.makeConnection()
+ threadid = thread.get_ident()
+ if (self._pool is not None
+ and self._threadPool.has_key(threadid)):
+ conn = self._threadPool[threadid]
+ del self._threadPool[threadid]
+ if conn in self._pool:
+ self._pool.remove(conn)
+ else:
+ conn = self.makeConnection()
+ if self._pool is not None:
+ self._threadOrigination[id(conn)] = threadid
+ self._connectionNumbers[id(conn)] = self._connectionCount
+ self._connectionCount += 1
+ if self.debug:
+ s = 'ACQUIRE'
+ if self._pool is not None:
+ s += ' pool=[%s]' % ', '.join([str(self._connectionNumbers[id(v)]) for v in self._pool])
+ self.printDebug(conn, s, 'Pool')
+ return conn
+
+ def releaseConnection(self, conn, explicit=False):
+ if self._memory:
+ return
+ threadid = self._threadOrigination.get(id(conn))
+ DBAPI.releaseConnection(self, conn, explicit=explicit)
+ if (self._pool is not None and threadid
+ and not self._threadPool.has_key(threadid)):
+ self._threadPool[threadid] = conn
+ else:
+ if self._pool and conn in self._pool:
+ self._pool.remove(conn)
+ conn.close()
+
def _setAutoCommit(self, conn, auto):
if using_sqlite2:
if auto:
@@ -91,7 +143,9 @@
conn.isolation_level = level
def makeConnection(self):
- return self._conn
+ if self._memory:
+ return self._memoryConn
+ return sqlite.connect(self.filename, **self._connOptions)
def _queryInsertID(self, conn, soInstance, id, names, values):
table = soInstance.sqlmeta.table
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_paste.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_paste.py 2006-01-23 06:02:07 UTC (rev 1527)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_paste.py 2006-01-23 07:53:24 UTC (rev 1528)
@@ -3,7 +3,7 @@
try:
from sqlobject.wsgi_middleware import make_middleware
except ImportError:
- disable = True
+ disabled = True
class NameOnly(SQLObject):
name = StringCol()
Copied: home/phd/SQLObject/paramstyles/sqlobject/tests/test_sqlite_threaded.py (from rev 1527, SQLObject/trunk/sqlobject/tests/test_sqlite_threaded.py)
Property changes on: home/phd/SQLObject/paramstyles/sqlobject/tests/test_sqlite_threaded.py
___________________________________________________________________
Name: svn:eol-style
+ native
|
|
From: <sub...@co...> - 2006-01-23 04:39:43
|
Author: ianb
Date: 2006-01-22 21:39:34 -0700 (Sun, 22 Jan 2006)
New Revision: 1526
Added:
SQLObject/branches/0.7-bugfix/sqlobject/tests/test_sqlite_threaded.py
Modified:
SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
Log:
Merged 1522:1523 from trunk (SQLite threading fix)
Modified: SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-01-22 11:10:09 UTC (rev 1525)
+++ SQLObject/branches/0.7-bugfix/sqlobject/sqlite/sqliteconnection.py 2006-01-23 04:39:34 UTC (rev 1526)
@@ -1,5 +1,6 @@
from sqlobject.dbconnection import DBAPI
from sqlobject.col import popKey
+import thread
sqlite = None
using_sqlite2 = False
@@ -23,6 +24,12 @@
using_sqlite2 = False
self.module = sqlite
self.filename = filename # full path to sqlite-db-file
+ self._memory = filename == ':memory:'
+ if self._memory:
+ if not using_sqlite2:
+ raise ValueError(
+ "You must use sqlite2 to use in-memory databases")
+ #kw.setdefault('check_same_thread', False)
# connection options
opts = {}
if using_sqlite2:
@@ -58,8 +65,13 @@
opts['timeout'] = float(popKey(kw, 'timeout'))
# use only one connection for sqlite - supports multiple)
# cursors per connection
- self._conn = sqlite.connect(self.filename, **opts)
+ self._connOptions = opts
DBAPI.__init__(self, **kw)
+ self._threadPool = {}
+ self._threadOrigination = {}
+ if self._memory:
+ self._memoryConn = sqlite.connect(
+ self.filename, **self._connOptions)
def connectionFromURI(cls, uri):
user, password, host, port, path, args = cls._parseURI(uri)
@@ -69,13 +81,53 @@
assert user is None and password is None, (
"You may not provide usernames or passwords for SQLite "
"databases")
- if path == "/:memory:": path = ":memory:"
+ if path == "/:memory:":
+ path = ":memory:"
return cls(filename=path, **args)
connectionFromURI = classmethod(connectionFromURI)
def uri(self):
return 'sqlite:///%s' % self.filename
+ def getConnection(self):
+ # SQLite can't share connections between threads, and so can't
+ # pool connections. Since we are isolating threads here, we
+ # don't have to worry about locking as much.
+ if self._memory:
+ return self.makeConnection()
+ threadid = thread.get_ident()
+ if (self._pool is not None
+ and self._threadPool.has_key(threadid)):
+ conn = self._threadPool[threadid]
+ del self._threadPool[threadid]
+ if conn in self._pool:
+ self._pool.remove(conn)
+ else:
+ conn = self.makeConnection()
+ if self._pool is not None:
+ self._threadOrigination[id(conn)] = threadid
+ self._connectionNumbers[id(conn)] = self._connectionCount
+ self._connectionCount += 1
+ if self.debug:
+ s = 'ACQUIRE'
+ if self._pool is not None:
+ s += ' pool=[%s]' % ', '.join([str(self._connectionNumbers[id(v)]) for v in self._pool])
+ self.printDebug(conn, s, 'Pool')
+ return conn
+
+ def releaseConnection(self, conn, explicit=False):
+ if self._memory:
+ return
+ threadid = self._threadOrigination.get(id(conn))
+ DBAPI.releaseConnection(self, conn, explicit=explicit)
+ if (self._pool is not None and threadid
+ and not self._threadPool.has_key(threadid)):
+ self._threadPool[threadid] = conn
+ else:
+ if self._pool and conn in self._pool:
+ self._pool.remove(conn)
+ conn.close()
+
def _setAutoCommit(self, conn, auto):
if using_sqlite2:
if auto:
@@ -91,7 +143,9 @@
conn.isolation_level = level
def makeConnection(self):
- return self._conn
+ if self._memory:
+ return self._memoryConn
+ return sqlite.connect(self.filename, **self._connOptions)
def _queryInsertID(self, conn, soInstance, id, names, values):
table = soInstance.sqlmeta.table
Copied: SQLObject/branches/0.7-bugfix/sqlobject/tests/test_sqlite_threaded.py (from rev 1523, SQLObject/trunk/sqlobject/tests/test_sqlite_threaded.py)
|
|
From: SourceForge.net <no...@so...> - 2006-01-20 16:14:31
|
Bugs item #1410910, was opened at 2006-01-20 17:10 Message generated for change (Comment added) made by jt01 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1410910&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: Open Resolution: None Priority: 5 Submitted By: jt (jt01) Assigned to: Nobody/Anonymous (nobody) Summary: 0.7.0 __getattr__ should raise AttributeError Initial Comment: If 'foo' is not an attribute of obj, obj.q.foo should catch KeyError and raise an AttributeError. sqlbuilder.py +362 -------------------------------------------------- return self.FieldClass(self.tableName, self.soClass.sqlmeta.columns[attr].dbName, attr) -------------------------------------------------- I suppose some others __getattr__ have the same problem. ---------------------------------------------------------------------- >Comment By: jt (jt01) Date: 2006-01-20 17:14 Message: Logged In: YES user_id=1002407 and should have default value: getattr(object, 'method', default) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1410910&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-20 16:10:14
|
Bugs item #1410910, was opened at 2006-01-20 17:10 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=1410910&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: Open Resolution: None Priority: 5 Submitted By: jt (jt01) Assigned to: Nobody/Anonymous (nobody) Summary: 0.7.0 __getattr__ should raise AttributeError Initial Comment: If 'foo' is not an attribute of obj, obj.q.foo should catch KeyError and raise an AttributeError. sqlbuilder.py +362 -------------------------------------------------- return self.FieldClass(self.tableName, self.soClass.sqlmeta.columns[attr].dbName, attr) -------------------------------------------------- I suppose some others __getattr__ have the same problem. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1410910&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-20 15:04:06
|
Patches item #1410834, was opened at 2006-01-20 15:21 Message generated for change (Comment added) made by linux4u You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1410834&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 Submitted By: Pau Aliagas (linux4u) Assigned to: Nobody/Anonymous (nobody) Summary: add RLIKE operator Initial Comment: Well, it looks like I'm inspired. I tried to do all the regular expression matching in python, but it was too slow, as I need to select records based on an expresion matching. So I have implemented RLIKE, also known as REGEXP or Posix Regular Expressions. You can use it as any other operator! mysql and firebird call it REGEXP and RLIKE postgres calls it ~ The rest just do not support it, so I've made it behave like "LIKE", as I did not find a standard manner not to support it. It's not a bad solution :) The patch is really trivial, I've tested it with many records (in mysql) and works as expected. I've tested the resulting SQL in postgres and it works too. Hope you can include it. ---------------------------------------------------------------------- >Comment By: Pau Aliagas (linux4u) Date: 2006-01-20 16:03 Message: Logged In: YES user_id=140558 Sorry, I attached the worng patch, this is the good one. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1410834&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-20 14:21:54
|
Patches item #1410834, was opened at 2006-01-20 15:21 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=1410834&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 Submitted By: Pau Aliagas (linux4u) Assigned to: Nobody/Anonymous (nobody) Summary: add RLIKE operator Initial Comment: Well, it looks like I'm inspired. I tried to do all the regular expression matching in python, but it was too slow, as I need to select records based on an expresion matching. So I have implemented RLIKE, also known as REGEXP or Posix Regular Expressions. You can use it as any other operator! mysql and firebird call it REGEXP and RLIKE postgres calls it ~ The rest just do not support it, so I've made it behave like "LIKE", as I did not find a standard manner not to support it. It's not a bad solution :) The patch is really trivial, I've tested it with many records (in mysql) and works as expected. I've tested the resulting SQL in postgres and it works too. Hope you can include it. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1410834&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-20 07:51:50
|
Patches item #1410527, was opened at 2006-01-20 08:42 Message generated for change (Comment added) made by linux4u You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1410527&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 Submitted By: Pau Aliagas (linux4u) Assigned to: Nobody/Anonymous (nobody) Summary: allow the use of foreign keys in selects (small jewel) Initial Comment: Many times you need to make a query that needs to filter using the foreign key. This should be trivial to do: just adding the foreign table or foreign table SHOULD work. But it does not. Better see the example: class handset_brand(SQLObject): brand = StringCol(alternateID = True, length = 50) handsets = SQLMultipleJoin('handset') class handset(SQLObject): handset_brand = ForeignKey('handset_brand') handset_made_in = ForeignKey('country') model = StringCol(alternateID = True, length = 25) class country(SQLObject): name StringCol(alternateID = True, length = 50) isocode StringCol(alternateID = True, length = 3) Query 1 ------- I want to query the handsets of one concrete brand. * solution 1 ---------- Now the best way to do it would be: handset_brands.get(4).handsets.filter(handset.q.model == "mymodel") but you NEED to define the MultipleJoin. * solution 2 ---------- You can use the dotq syntax: handset.select(handset.q.handset_brandID==4) For me the main problem is the you have to use the foreign key name defined in Style, so if you change the Style it would stop working. That's bad. * expected behaviour ------------------ I'd like to be able to do: handset.select(brandID = 4) or b = brand.get(4) handset.select(brand = b) One of both would be GREAT, but both would be AWSOME. This is the natural way of thinking. Query 2 ------- What if if want to filter using two foreign keys? For instance to query the handsets of one concrete brand made in one country. * solution 1 ---------- It would NOT work, you cannot query directly using both foreign tables. * solution 2 ---------- You can use the dotq syntax: handset.select(AND(handset.q.handset_brandID==4, handset.q.countryID==1)) Again, you have to use the foreign key name defined in Style. I try to avoid it, it feels like there SHOULD be a better way. * expected behaviour ------------------ I'd like to be able to do: handset.select(brandID = 4, countrID = 1) or b = brand.get(4) c = country.get(1) handset.select(brand = b, country = c) One of both, depending on the occasion, sometimes it would be better to use one way, sometimes the other one. In fact this is the way "INSERT" works!! Why not SELECT? The good news is that this small patch (3 lines) add this powerful features :) It really was trivial to do thanks to the well-designed code. Thanks very much for the hard work. As expected, it passes all the tests. ---------------------------------------------------------------------- >Comment By: Pau Aliagas (linux4u) Date: 2006-01-20 08:51 Message: Logged In: YES user_id=140558 There is a little mistake in the example: s/select/selectBy where it says: handset.select(brand = b, country = c) it should say: handset.selectBy(brand = b, country = c) This is how it really works (select always uses the dotq syntax). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1410527&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-20 07:42:41
|
Patches item #1410527, was opened at 2006-01-20 08:42 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=1410527&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 Submitted By: Pau Aliagas (linux4u) Assigned to: Nobody/Anonymous (nobody) Summary: allow the use of foreign keys in selects (small jewel) Initial Comment: Many times you need to make a query that needs to filter using the foreign key. This should be trivial to do: just adding the foreign table or foreign table SHOULD work. But it does not. Better see the example: class handset_brand(SQLObject): brand = StringCol(alternateID = True, length = 50) handsets = SQLMultipleJoin('handset') class handset(SQLObject): handset_brand = ForeignKey('handset_brand') handset_made_in = ForeignKey('country') model = StringCol(alternateID = True, length = 25) class country(SQLObject): name StringCol(alternateID = True, length = 50) isocode StringCol(alternateID = True, length = 3) Query 1 ------- I want to query the handsets of one concrete brand. * solution 1 ---------- Now the best way to do it would be: handset_brands.get(4).handsets.filter(handset.q.model == "mymodel") but you NEED to define the MultipleJoin. * solution 2 ---------- You can use the dotq syntax: handset.select(handset.q.handset_brandID==4) For me the main problem is the you have to use the foreign key name defined in Style, so if you change the Style it would stop working. That's bad. * expected behaviour ------------------ I'd like to be able to do: handset.select(brandID = 4) or b = brand.get(4) handset.select(brand = b) One of both would be GREAT, but both would be AWSOME. This is the natural way of thinking. Query 2 ------- What if if want to filter using two foreign keys? For instance to query the handsets of one concrete brand made in one country. * solution 1 ---------- It would NOT work, you cannot query directly using both foreign tables. * solution 2 ---------- You can use the dotq syntax: handset.select(AND(handset.q.handset_brandID==4, handset.q.countryID==1)) Again, you have to use the foreign key name defined in Style. I try to avoid it, it feels like there SHOULD be a better way. * expected behaviour ------------------ I'd like to be able to do: handset.select(brandID = 4, countrID = 1) or b = brand.get(4) c = country.get(1) handset.select(brand = b, country = c) One of both, depending on the occasion, sometimes it would be better to use one way, sometimes the other one. In fact this is the way "INSERT" works!! Why not SELECT? The good news is that this small patch (3 lines) add this powerful features :) It really was trivial to do thanks to the well-designed code. Thanks very much for the hard work. As expected, it passes all the tests. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1410527&group_id=74338 |
|
From: <sub...@co...> - 2006-01-19 16:19:22
|
Author: ianb Date: 2006-01-19 09:19:12 -0700 (Thu, 19 Jan 2006) New Revision: 1524 Modified: SQLObject/docs/index.comments.txt Log: in page: http://pythonpaste.org/ by: pippo Add comment Modified: SQLObject/docs/index.comments.txt =================================================================== --- SQLObject/docs/index.comments.txt 2006-01-19 09:54:27 UTC (rev 1523) +++ SQLObject/docs/index.comments.txt 2006-01-19 16:19:12 UTC (rev 1524) @@ -0,0 +1,8 @@ +==== $(documentation) c +---------------------------------------- +date: 2006-01-19T09:19:09 +id: 1 +ip: 62.101.91.106 +username: pippo + +grande |
|
From: <sub...@co...> - 2006-01-19 09:54:32
|
Author: ianb
Date: 2006-01-19 02:54:27 -0700 (Thu, 19 Jan 2006)
New Revision: 1523
Added:
SQLObject/trunk/sqlobject/tests/test_sqlite_threaded.py
Modified:
SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
Log:
Fixed problem with sqlite and threads; connections are no longer shared between threads for sqlite (except for :memory:)
Modified: SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-01-19 09:53:33 UTC (rev 1522)
+++ SQLObject/trunk/sqlobject/sqlite/sqliteconnection.py 2006-01-19 09:54:27 UTC (rev 1523)
@@ -1,5 +1,6 @@
from sqlobject.dbconnection import DBAPI
from sqlobject.col import popKey
+import thread
sqlite = None
using_sqlite2 = False
@@ -23,6 +24,12 @@
using_sqlite2 = False
self.module = sqlite
self.filename = filename # full path to sqlite-db-file
+ self._memory = filename == ':memory:'
+ if self._memory:
+ if not using_sqlite2:
+ raise ValueError(
+ "You must use sqlite2 to use in-memory databases")
+ #kw.setdefault('check_same_thread', False)
# connection options
opts = {}
if using_sqlite2:
@@ -58,8 +65,13 @@
opts['timeout'] = float(popKey(kw, 'timeout'))
# use only one connection for sqlite - supports multiple)
# cursors per connection
- self._conn = sqlite.connect(self.filename, **opts)
+ self._connOptions = opts
DBAPI.__init__(self, **kw)
+ self._threadPool = {}
+ self._threadOrigination = {}
+ if self._memory:
+ self._memoryConn = sqlite.connect(
+ self.filename, **self._connOptions)
def connectionFromURI(cls, uri):
user, password, host, port, path, args = cls._parseURI(uri)
@@ -69,13 +81,53 @@
assert user is None and password is None, (
"You may not provide usernames or passwords for SQLite "
"databases")
- if path == "/:memory:": path = ":memory:"
+ if path == "/:memory:":
+ path = ":memory:"
return cls(filename=path, **args)
connectionFromURI = classmethod(connectionFromURI)
def uri(self):
return 'sqlite:///%s' % self.filename
+ def getConnection(self):
+ # SQLite can't share connections between threads, and so can't
+ # pool connections. Since we are isolating threads here, we
+ # don't have to worry about locking as much.
+ if self._memory:
+ return self.makeConnection()
+ threadid = thread.get_ident()
+ if (self._pool is not None
+ and self._threadPool.has_key(threadid)):
+ conn = self._threadPool[threadid]
+ del self._threadPool[threadid]
+ if conn in self._pool:
+ self._pool.remove(conn)
+ else:
+ conn = self.makeConnection()
+ if self._pool is not None:
+ self._threadOrigination[id(conn)] = threadid
+ self._connectionNumbers[id(conn)] = self._connectionCount
+ self._connectionCount += 1
+ if self.debug:
+ s = 'ACQUIRE'
+ if self._pool is not None:
+ s += ' pool=[%s]' % ', '.join([str(self._connectionNumbers[id(v)]) for v in self._pool])
+ self.printDebug(conn, s, 'Pool')
+ return conn
+
+ def releaseConnection(self, conn, explicit=False):
+ if self._memory:
+ return
+ threadid = self._threadOrigination.get(id(conn))
+ DBAPI.releaseConnection(self, conn, explicit=explicit)
+ if (self._pool is not None and threadid
+ and not self._threadPool.has_key(threadid)):
+ self._threadPool[threadid] = conn
+ else:
+ if self._pool and conn in self._pool:
+ self._pool.remove(conn)
+ conn.close()
+
def _setAutoCommit(self, conn, auto):
if using_sqlite2:
if auto:
@@ -91,7 +143,9 @@
conn.isolation_level = level
def makeConnection(self):
- return self._conn
+ if self._memory:
+ return self._memoryConn
+ return sqlite.connect(self.filename, **self._connOptions)
def _queryInsertID(self, conn, soInstance, id, names, values):
table = soInstance.sqlmeta.table
Added: SQLObject/trunk/sqlobject/tests/test_sqlite_threaded.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_sqlite_threaded.py 2006-01-19 09:53:33 UTC (rev 1522)
+++ SQLObject/trunk/sqlobject/tests/test_sqlite_threaded.py 2006-01-19 09:54:27 UTC (rev 1523)
@@ -0,0 +1,17 @@
+from dbtest import *
+from test_basic import TestSO1
+import threading
+
+def test_sqlite_threaded():
+ setupClass(TestSO1)
+ t = threading.Thread(target=do_select)
+ t.start()
+ t.join()
+ # This should reuse the same connection as the connection
+ # made above (at least will with most database drivers, but
+ # this will cause an error in SQLite):
+ do_select()
+
+def do_select():
+ list(TestSO1.select())
+ print "T", threading.currentThread().getName()
Property changes on: SQLObject/trunk/sqlobject/tests/test_sqlite_threaded.py
___________________________________________________________________
Name: svn:eol-style
+ native
|
|
From: <sub...@co...> - 2006-01-19 09:53:39
|
Author: ianb
Date: 2006-01-19 02:53:33 -0700 (Thu, 19 Jan 2006)
New Revision: 1522
Modified:
SQLObject/docs/SQLObject.txt
Log:
Updated style of _fromDatabase
Modified: SQLObject/docs/SQLObject.txt
===================================================================
--- SQLObject/docs/SQLObject.txt 2006-01-19 09:52:56 UTC (rev 1521)
+++ SQLObject/docs/SQLObject.txt 2006-01-19 09:53:33 UTC (rev 1522)
@@ -1346,9 +1346,9 @@
attribute). Do this like::
class Person(SQLObject):
+ class sqlmeta:
+ fromDatabase = True
- _fromDatabase = True
-
You can still specify columns (in `_columns`), and only missing
columns will be added.
|
|
From: <sub...@co...> - 2006-01-19 09:53:14
|
Author: ianb
Date: 2006-01-19 02:52:56 -0700 (Thu, 19 Jan 2006)
New Revision: 1521
Modified:
SQLObject/trunk/sqlobject/col.py
Log:
Fixed problem with DecimalCol error message
Modified: SQLObject/trunk/sqlobject/col.py
===================================================================
--- SQLObject/trunk/sqlobject/col.py 2006-01-18 15:56:11 UTC (rev 1520)
+++ SQLObject/trunk/sqlobject/col.py 2006-01-19 09:52:56 UTC (rev 1521)
@@ -1153,8 +1153,8 @@
try:
return Decimal(value)
except:
- raise validators.Invalid("can not parse Decimal value '%s' in the DecimalCol '%s'" %
- (value, self.name), value, state)
+ raise validators.Invalid("can not parse Decimal value '%s' in the DecimalCol from '%s'" %
+ (value, getattr(state, 'soObject', '(unknown)')), value, state)
if not isinstance(value, (int, long, Decimal, sqlbuilder.SQLExpression)):
raise validators.Invalid("expected a decimal in the DecimalCol '%s', got %s %r instead" % \
(self.name, type(value), value), value, state)
|
|
From: SourceForge.net <no...@so...> - 2006-01-18 16:04:38
|
Patches item #1353728, was opened at 2005-11-11 08:20 Message generated for change (Comment added) made by linux4u You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1353728&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: Invalid Priority: 5 Submitted By: Pau Aliagas (linux4u) Assigned to: Oleg Broytmann (phd) Summary: define foreign keys in Style Initial Comment: I don't like to use attrID all along the code to access related tables, I want to be able use the nomeclature I like taking advantage of the nice Style idea. This is especially true when you create RelatedJoins when you use a nomeclature like I do (table.id_table), but it's the same for all the nomeclatures you can imagine. In styles.py it warns: def instanceAttrToIDAttr(self, attr): # @@: Right now, because of how names are created for foreign # keys, you can't really change this style. return attr + "ID" With this patch you can define how you want the foreign keys generated, they won't be mandatorily generated as attrID. Example: class LongStyle(Style): """ This style is derived from Style, that does not do any translation, but constructs the table ids like id_table. """ def instanceAttrToIDAttr(self, attr): return "id_" + attr def tableReference(self, table): # str.rsplit is python 2.4+ only if version_info >= (2, 4): return "id_" + table.rsplit(".", 1)[-1] else: return "id_" + rsplit(table, ".", 1)[-1] class mm_server(SQLObject): class sqlmeta: table = "smsarena.mm_server" style = LongStyle(longID = True) _connection = conn_smsarena server = StringCol(alternateID = True, varchar = True, length = 255, alternateMethodName = "by_server") tz = StringCol(length = 20, default = 'CET', notNone = True) conutry_code = StringCol(length = 2, varchar = False, default = '', notNone = True) # until now I had to do this # mm_server_aliases = SQLMultipleJoin("mm_server_alias", joinColumn = "mm_serverID", orderBy = "server") # now it's perfect! mm_server_aliases = SQLMultipleJoin("mm_server_alias", orderBy = "server") class mm_server_alias(SQLObject): class sqlmeta: table = "smsarena.mm_server_alias" style = LongStyle(longID = True) _connection = conn_smsarena # until now I had to do this # mm_server = ForeignKey("mm_server", dbName = "id_mm_server") mm_server = ForeignKey("mm_server") server = StringCol(alternateID = True, varchar = True, length = 255, alternateMethodName = "by_server") I hope it's clear :) Pau ---------------------------------------------------------------------- >Comment By: Pau Aliagas (linux4u) Date: 2006-01-18 17:04 Message: Logged In: YES user_id=140558 This is the final patch against latest svn, it includes everything in one single patch. It passes the tests. ---------------------------------------------------------------------- Comment By: Pau Aliagas (linux4u) Date: 2006-01-18 14:17 Message: Logged In: YES user_id=140558 Ok, I have taken my time to understand pydist, test, etc, and here I am back with the working solution :) Now the resulting SQLobject passes all the tests. I attach an incremental patch so that you can see more clearly the changes done to fix the previous one. I've needed a new method in the Style class, instanceIDAttrToAttr, that is the complementary to the already known instanceAttrToIDAttr. If you need to transform back and forth field names, you need them both. I haven't tried to port it to the latest svn yet, this is against the same release than the first patch, but it should apply more or less clearly as this are very isolated areas in the code. When I do it I'll post it here. Sorry for the delay, it has not been easy for me to understand more deeply the code and, even less, to know how the tests work :) ---------------------------------------------------------------------- Comment By: Pau Aliagas (linux4u) Date: 2006-01-03 13:18 Message: Logged In: YES user_id=140558 It fails because the test is not right, it still has the ID postfix hardcoded. My fault, I did no send a patch for tests. This is the piece that fails: # Select by usual way s = TestWorkKey.selectBy(composerID=c.id, title='Symphony No. 9') I have not looked at tests until now, but it looks like there should be tests for the different provides styles, in this case, if you accept the patch, at least a test for the LongStyle provided and for the current naming styles. I'll try to cook up something, but it can take a little time. Any guidelines will be appreciated (I've just read the docs ;) ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-01-03 12:23 Message: Logged In: YES user_id=4799 test_selectBy_foreignKey.py fails: def test1(): setupClass([TestComposerKey, TestWorkKey]) c = TestComposerKey(name='Mahler, Gustav') > w1 = TestWorkKey(composer=c, title='Symphony No. 9') [/home/phd/work/SQLObject/SQLObject-patches/sqlobject/tests/test_selectBy_foreignKey.py:19] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def __init__(self, **kw): # The get() classmethod/constructor uses a magic keyword # argument when it wants an empty object, fetched from the # database. So we have nothing more to do in that case: if kw.has_key('_SO_fetch_no_create'): return post_funcs = [] self.sqlmeta.send(events.RowCreateSignal, kw, post_funcs) # 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'] self._SO_writeLock = threading.Lock() if kw.has_key('id'): id = self.sqlmeta.idType(kw['id']) del kw['id'] else: id = None > self._create(id, **kw) [/home/phd/work/SQLObject/SQLObject-patches/sqlobject/main.py:1210] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def _create(self, id, **kw): self.sqlmeta._creating = True self._SO_createValues = {} self._SO_validatorState = SQLObjectState(self) # First we do a little fix-up on the keywords we were # passed: for column in self.sqlmeta.columnList: # Then we check if the column wasn't passed in, and # if not we try to get the default. if not kw.has_key(column.name) and not kw.has_key(column.foreignName): default = column.default # If we don't get it, it's an error: if default is NoDefault: E raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, column.name) > TypeError: TestWorkKey() did not get expected keyword argument composerID [/home/phd/work/SQLObject/SQLObject-patches/sqlobject/main.py:1231] - - - - - - - - - - - - - test1: recorded stdout - - - - - - - - - - - - - - 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/COMMIT : auto 1/Query : CREATE TABLE test_composer_key ( id SERIAL PRIMARY KEY, name TEXT ) 1/QueryR : CREATE TABLE test_composer_key ( id SERIAL PRIMARY KEY, name TEXT ) 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/COMMIT : auto 1/Query : CREATE TABLE test_work_key ( work_id SERIAL PRIMARY KEY, composer_id INT, title TEXT ) 1/QueryR : CREATE TABLE test_work_key ( work_id SERIAL PRIMARY KEY, composer_id INT, title TEXT ) 1/COMMIT : auto 1/Query : ALTER TABLE test_work_key ADD CONSTRAINT composer_id_exists FOREIGN KEY (composer_id) REFERENCES test_composer_key (id) 1/QueryR : ALTER TABLE test_work_key ADD CONSTRAINT composer_id_exists FOREIGN KEY (composer_id) REFERENCES test_composer_key (id) 1/COMMIT : auto 1/QueryIns: INSERT INTO test_composer_key (id, name) VALUES (1, 'Mahler, Gustav') 1/COMMIT : auto 1/QueryOne: SELECT name FROM test_composer_key WHERE id = 1 1/QueryR : SELECT name FROM test_composer_key WHERE id = 1 1/COMMIT : auto ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1353728&group_id=74338 |
|
From: <sub...@co...> - 2006-01-18 15:56:17
|
Author: ianb Date: 2006-01-18 08:56:11 -0700 (Wed, 18 Jan 2006) New Revision: 1520 Modified: SQLObject/docs/SQLObject.comments.txt Log: Web updates Modified: SQLObject/docs/SQLObject.comments.txt =================================================================== --- SQLObject/docs/SQLObject.comments.txt 2006-01-17 08:55:23 UTC (rev 1519) +++ SQLObject/docs/SQLObject.comments.txt 2006-01-18 15:56:11 UTC (rev 1520) @@ -25,15 +25,6 @@ username: Mike Kent So if you declare a column as an alternateID, unique is implied, and we don't need to explicitly declare it? -==== $(orderby) ++++++++ c + ----------------------------------------- -date: 2005-12-08T10:44:37 -email: ch...@wo... -id: 7 -ip: 134.84.144.61 -username: Chad Walstrom - -This note renders poorly in Firefox 1.0.x. The only way to see it is to mouse-over, at which point it displays as red-text. ==== $(orderby) + ---------------------------------------- date: 2005-12-08T10:47:35 |
|
From: SourceForge.net <no...@so...> - 2006-01-18 13:17:26
|
Patches item #1353728, was opened at 2005-11-11 08:20 Message generated for change (Comment added) made by linux4u You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1353728&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: Invalid Priority: 5 Submitted By: Pau Aliagas (linux4u) Assigned to: Oleg Broytmann (phd) Summary: define foreign keys in Style Initial Comment: I don't like to use attrID all along the code to access related tables, I want to be able use the nomeclature I like taking advantage of the nice Style idea. This is especially true when you create RelatedJoins when you use a nomeclature like I do (table.id_table), but it's the same for all the nomeclatures you can imagine. In styles.py it warns: def instanceAttrToIDAttr(self, attr): # @@: Right now, because of how names are created for foreign # keys, you can't really change this style. return attr + "ID" With this patch you can define how you want the foreign keys generated, they won't be mandatorily generated as attrID. Example: class LongStyle(Style): """ This style is derived from Style, that does not do any translation, but constructs the table ids like id_table. """ def instanceAttrToIDAttr(self, attr): return "id_" + attr def tableReference(self, table): # str.rsplit is python 2.4+ only if version_info >= (2, 4): return "id_" + table.rsplit(".", 1)[-1] else: return "id_" + rsplit(table, ".", 1)[-1] class mm_server(SQLObject): class sqlmeta: table = "smsarena.mm_server" style = LongStyle(longID = True) _connection = conn_smsarena server = StringCol(alternateID = True, varchar = True, length = 255, alternateMethodName = "by_server") tz = StringCol(length = 20, default = 'CET', notNone = True) conutry_code = StringCol(length = 2, varchar = False, default = '', notNone = True) # until now I had to do this # mm_server_aliases = SQLMultipleJoin("mm_server_alias", joinColumn = "mm_serverID", orderBy = "server") # now it's perfect! mm_server_aliases = SQLMultipleJoin("mm_server_alias", orderBy = "server") class mm_server_alias(SQLObject): class sqlmeta: table = "smsarena.mm_server_alias" style = LongStyle(longID = True) _connection = conn_smsarena # until now I had to do this # mm_server = ForeignKey("mm_server", dbName = "id_mm_server") mm_server = ForeignKey("mm_server") server = StringCol(alternateID = True, varchar = True, length = 255, alternateMethodName = "by_server") I hope it's clear :) Pau ---------------------------------------------------------------------- >Comment By: Pau Aliagas (linux4u) Date: 2006-01-18 14:17 Message: Logged In: YES user_id=140558 Ok, I have taken my time to understand pydist, test, etc, and here I am back with the working solution :) Now the resulting SQLobject passes all the tests. I attach an incremental patch so that you can see more clearly the changes done to fix the previous one. I've needed a new method in the Style class, instanceIDAttrToAttr, that is the complementary to the already known instanceAttrToIDAttr. If you need to transform back and forth field names, you need them both. I haven't tried to port it to the latest svn yet, this is against the same release than the first patch, but it should apply more or less clearly as this are very isolated areas in the code. When I do it I'll post it here. Sorry for the delay, it has not been easy for me to understand more deeply the code and, even less, to know how the tests work :) ---------------------------------------------------------------------- Comment By: Pau Aliagas (linux4u) Date: 2006-01-03 13:18 Message: Logged In: YES user_id=140558 It fails because the test is not right, it still has the ID postfix hardcoded. My fault, I did no send a patch for tests. This is the piece that fails: # Select by usual way s = TestWorkKey.selectBy(composerID=c.id, title='Symphony No. 9') I have not looked at tests until now, but it looks like there should be tests for the different provides styles, in this case, if you accept the patch, at least a test for the LongStyle provided and for the current naming styles. I'll try to cook up something, but it can take a little time. Any guidelines will be appreciated (I've just read the docs ;) ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2006-01-03 12:23 Message: Logged In: YES user_id=4799 test_selectBy_foreignKey.py fails: def test1(): setupClass([TestComposerKey, TestWorkKey]) c = TestComposerKey(name='Mahler, Gustav') > w1 = TestWorkKey(composer=c, title='Symphony No. 9') [/home/phd/work/SQLObject/SQLObject-patches/sqlobject/tests/test_selectBy_foreignKey.py:19] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def __init__(self, **kw): # The get() classmethod/constructor uses a magic keyword # argument when it wants an empty object, fetched from the # database. So we have nothing more to do in that case: if kw.has_key('_SO_fetch_no_create'): return post_funcs = [] self.sqlmeta.send(events.RowCreateSignal, kw, post_funcs) # 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'] self._SO_writeLock = threading.Lock() if kw.has_key('id'): id = self.sqlmeta.idType(kw['id']) del kw['id'] else: id = None > self._create(id, **kw) [/home/phd/work/SQLObject/SQLObject-patches/sqlobject/main.py:1210] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def _create(self, id, **kw): self.sqlmeta._creating = True self._SO_createValues = {} self._SO_validatorState = SQLObjectState(self) # First we do a little fix-up on the keywords we were # passed: for column in self.sqlmeta.columnList: # Then we check if the column wasn't passed in, and # if not we try to get the default. if not kw.has_key(column.name) and not kw.has_key(column.foreignName): default = column.default # If we don't get it, it's an error: if default is NoDefault: E raise TypeError, "%s() did not get expected keyword argument %s" % (self.__class__.__name__, column.name) > TypeError: TestWorkKey() did not get expected keyword argument composerID [/home/phd/work/SQLObject/SQLObject-patches/sqlobject/main.py:1231] - - - - - - - - - - - - - test1: recorded stdout - - - - - - - - - - - - - - 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_composer_key' 1/COMMIT : auto 1/Query : CREATE TABLE test_composer_key ( id SERIAL PRIMARY KEY, name TEXT ) 1/QueryR : CREATE TABLE test_composer_key ( id SERIAL PRIMARY KEY, name TEXT ) 1/COMMIT : auto 1/QueryOne: SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/QueryR : SELECT COUNT(relname) FROM pg_class WHERE relname = 'test_work_key' 1/COMMIT : auto 1/Query : CREATE TABLE test_work_key ( work_id SERIAL PRIMARY KEY, composer_id INT, title TEXT ) 1/QueryR : CREATE TABLE test_work_key ( work_id SERIAL PRIMARY KEY, composer_id INT, title TEXT ) 1/COMMIT : auto 1/Query : ALTER TABLE test_work_key ADD CONSTRAINT composer_id_exists FOREIGN KEY (composer_id) REFERENCES test_composer_key (id) 1/QueryR : ALTER TABLE test_work_key ADD CONSTRAINT composer_id_exists FOREIGN KEY (composer_id) REFERENCES test_composer_key (id) 1/COMMIT : auto 1/QueryIns: INSERT INTO test_composer_key (id, name) VALUES (1, 'Mahler, Gustav') 1/COMMIT : auto 1/QueryOne: SELECT name FROM test_composer_key WHERE id = 1 1/QueryR : SELECT name FROM test_composer_key WHERE id = 1 1/COMMIT : auto ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1353728&group_id=74338 |
|
From: <sub...@co...> - 2006-01-17 03:06:26
|
Author: ianb
Date: 2006-01-16 20:06:14 -0700 (Mon, 16 Jan 2006)
New Revision: 1518
Modified:
SQLObject/trunk/sqlobject/tests/test_paste.py
Log:
Spell disabled properly
Modified: SQLObject/trunk/sqlobject/tests/test_paste.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_paste.py 2006-01-16 17:32:21 UTC (rev 1517)
+++ SQLObject/trunk/sqlobject/tests/test_paste.py 2006-01-17 03:06:14 UTC (rev 1518)
@@ -3,7 +3,7 @@
try:
from sqlobject.wsgi_middleware import make_middleware
except ImportError:
- disable = True
+ disabled = True
class NameOnly(SQLObject):
name = StringCol()
|
|
From: SourceForge.net <no...@so...> - 2006-01-16 21:39:10
|
Patches item #1407684, was opened at 2006-01-16 13:35 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1407684&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 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: object initialization threading issue Initial Comment: The creation of SQL objects is not threadsafe. After stressing a TurboGears app with ab2 with multiple concurrent connections to a threaded server, the log gets filled with tracebacks like these: 15/Jan/2006:22:05:00 HTTP INFO Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/_cp httptools.py", line 96, in _run applyFilters('before_main') File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/fil ters/__init__.py", line 131, in applyFilters method() File "/home/alberto/turbogears/turbogears/visit.py", line 99, in beforeMain visit=self.get_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 139, in get_visit return self.new_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 122, in new_visit visit= TG_Visit( visit_key=visit_key, expiry=now+self.timeout ) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1197, in __init__ self._create(id, **kw) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1221, in _create self.set(**kw) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1142, in set self._connection._SO_update(self, args) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/dbconnection.py", line 561, in _SO_update self.query("UPDATE %s SET %s WHERE %s = %s" % AttributeError: 'TG_Visit' object has no attribute 'id' 15/Jan/2006:22:05:00 HTTP INFO Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/_cp httptools.py", line 96, in _run applyFilters('before_main') File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/fil ters/__init__.py", line 131, in applyFilters method() File "/home/alberto/turbogears/turbogears/visit.py", line 99, in beforeMain visit=self.get_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 139, in get_visit return self.new_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 122, in new_visit visit= TG_Visit( visit_key=visit_key, expiry=now+self.timeout ) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1197, in __init__ self._create(id, **kw) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1224, in _create self._SO_finishCreate(id) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1242, in _SO_finishCreate del self.sqlmeta._creating AttributeError: _creating I've found at http://pythonpaste.org/archives/message/ 20051202.223718.a3adcfaa.en.html a solution to the problem, which is overriding __init__ on SQLObject subclasses by wrapping SQLObject.__init__ with a mutex acquisition and release. I've made a patch for main.py which generalizes this approach and wraps __init__ for every SQLObject created. Tested under my environment and works fine. The patch is also posted at the turbogears Trac at http:// trac.turbogears.org/turbogears/attachment/ticket/397/ sqlobject_threading.patch Cheers, Alberto Valverde al...@to... ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2006-01-16 13:39 Message: Logged In: NO Ooops, typo: the patch is for declarative.py, not main.py ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1407684&group_id=74338 |
|
From: SourceForge.net <no...@so...> - 2006-01-16 21:35:47
|
Patches item #1407684, was opened at 2006-01-16 13:35 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=1407684&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 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: object initialization threading issue Initial Comment: The creation of SQL objects is not threadsafe. After stressing a TurboGears app with ab2 with multiple concurrent connections to a threaded server, the log gets filled with tracebacks like these: 15/Jan/2006:22:05:00 HTTP INFO Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/_cp httptools.py", line 96, in _run applyFilters('before_main') File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/fil ters/__init__.py", line 131, in applyFilters method() File "/home/alberto/turbogears/turbogears/visit.py", line 99, in beforeMain visit=self.get_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 139, in get_visit return self.new_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 122, in new_visit visit= TG_Visit( visit_key=visit_key, expiry=now+self.timeout ) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1197, in __init__ self._create(id, **kw) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1221, in _create self.set(**kw) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1142, in set self._connection._SO_update(self, args) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/dbconnection.py", line 561, in _SO_update self.query("UPDATE %s SET %s WHERE %s = %s" % AttributeError: 'TG_Visit' object has no attribute 'id' 15/Jan/2006:22:05:00 HTTP INFO Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/_cp httptools.py", line 96, in _run applyFilters('before_main') File "/usr/lib/python2.4/site-packages/CherryPy-2.2.0beta-py2.4.egg/ cherrypy/fil ters/__init__.py", line 131, in applyFilters method() File "/home/alberto/turbogears/turbogears/visit.py", line 99, in beforeMain visit=self.get_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 139, in get_visit return self.new_visit() File "/home/alberto/turbogears/turbogears/visit.py", line 122, in new_visit visit= TG_Visit( visit_key=visit_key, expiry=now+self.timeout ) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1197, in __init__ self._create(id, **kw) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1224, in _create self._SO_finishCreate(id) File "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1500- py2.4.egg/sqlobj ect/main.py", line 1242, in _SO_finishCreate del self.sqlmeta._creating AttributeError: _creating I've found at http://pythonpaste.org/archives/message/ 20051202.223718.a3adcfaa.en.html a solution to the problem, which is overriding __init__ on SQLObject subclasses by wrapping SQLObject.__init__ with a mutex acquisition and release. I've made a patch for main.py which generalizes this approach and wraps __init__ for every SQLObject created. Tested under my environment and works fine. The patch is also posted at the turbogears Trac at http:// trac.turbogears.org/turbogears/attachment/ticket/397/ sqlobject_threading.patch Cheers, Alberto Valverde al...@to... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1407684&group_id=74338 |