sqlobject-discuss Mailing List for SQLObject (Page 45)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
(2) |
Mar
(43) |
Apr
(204) |
May
(208) |
Jun
(102) |
Jul
(113) |
Aug
(63) |
Sep
(88) |
Oct
(85) |
Nov
(95) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(38) |
Feb
(93) |
Mar
(125) |
Apr
(89) |
May
(66) |
Jun
(65) |
Jul
(53) |
Aug
(65) |
Sep
(79) |
Oct
(60) |
Nov
(171) |
Dec
(176) |
2005 |
Jan
(264) |
Feb
(260) |
Mar
(145) |
Apr
(153) |
May
(192) |
Jun
(166) |
Jul
(265) |
Aug
(340) |
Sep
(300) |
Oct
(469) |
Nov
(316) |
Dec
(235) |
2006 |
Jan
(236) |
Feb
(156) |
Mar
(229) |
Apr
(221) |
May
(257) |
Jun
(161) |
Jul
(97) |
Aug
(169) |
Sep
(159) |
Oct
(400) |
Nov
(136) |
Dec
(134) |
2007 |
Jan
(152) |
Feb
(101) |
Mar
(115) |
Apr
(120) |
May
(129) |
Jun
(82) |
Jul
(118) |
Aug
(82) |
Sep
(30) |
Oct
(101) |
Nov
(137) |
Dec
(53) |
2008 |
Jan
(83) |
Feb
(139) |
Mar
(55) |
Apr
(69) |
May
(82) |
Jun
(31) |
Jul
(66) |
Aug
(30) |
Sep
(21) |
Oct
(37) |
Nov
(41) |
Dec
(65) |
2009 |
Jan
(69) |
Feb
(46) |
Mar
(22) |
Apr
(20) |
May
(39) |
Jun
(30) |
Jul
(36) |
Aug
(58) |
Sep
(38) |
Oct
(20) |
Nov
(10) |
Dec
(11) |
2010 |
Jan
(24) |
Feb
(63) |
Mar
(22) |
Apr
(72) |
May
(8) |
Jun
(13) |
Jul
(35) |
Aug
(23) |
Sep
(12) |
Oct
(26) |
Nov
(11) |
Dec
(30) |
2011 |
Jan
(15) |
Feb
(44) |
Mar
(36) |
Apr
(26) |
May
(27) |
Jun
(10) |
Jul
(28) |
Aug
(12) |
Sep
|
Oct
|
Nov
(17) |
Dec
(16) |
2012 |
Jan
(12) |
Feb
(31) |
Mar
(23) |
Apr
(14) |
May
(10) |
Jun
(26) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(6) |
2013 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(4) |
May
(13) |
Jun
(7) |
Jul
(5) |
Aug
(15) |
Sep
(25) |
Oct
(18) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(5) |
Sep
|
Oct
(11) |
Nov
|
Dec
(62) |
2015 |
Jan
(8) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(6) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(19) |
2016 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
(7) |
Jul
(14) |
Aug
(13) |
Sep
(6) |
Oct
(2) |
Nov
(3) |
Dec
|
2017 |
Jan
(6) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
(44) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Oleg B. <ph...@ph...> - 2010-01-15 16:16:28
|
Hello! On Wed, May 13, 2009 at 07:11:22PM +0000, Matthew Wilson wrote: > Hi -- I wrote some code to add a TimedeltaCol type. I only tested it in > postgresql. I applied both your patches to the trunk, commit 4088. Thank you! Sorry it took so long. > By the way, how do I write a converter that converts a python object one > way for one database (sqlite) and another way for another database > (postgres)? Are there any examples of this already? > +def TimedeltaConverter(value, db): > + > + return """INTERVAL '%d days %d seconds'""" % \ > + (value.days, value.seconds) db is the name of the database. See StringLikeConverter for an example. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-01-08 21:21:51
|
On Fri, Jan 08, 2010 at 06:58:25PM +0100, Markus Gritsch wrote: > I just diffed 0.12.0 with 0.12.1. I saw the 'ascii' change and > changes in Postgres and Firebird Connection, but either I overlooked > it, or there is no change regarding the cache culling algorithm. > > Are you sure it made it into the release? Yes, commits 4028-4030 (branches 0.10, 0.11, and the trunk). It was at October 9: http://sourceforge.net/mailarchive/forum.php?thread_name=E1MwHJk-0000Rj-00%40webwareforpython.org&forum_name=sqlobject-cvs http://sourceforge.net/mailarchive/forum.php?thread_name=E1MwHMU-0000VM-00%40webwareforpython.org&forum_name=sqlobject-cvs http://sourceforge.net/mailarchive/forum.php?thread_name=E1MwHO6-0000XY-00%40webwareforpython.org&forum_name=sqlobject-cvs Aha, I see, the new algorithm was in 0.12.0 - it was released at Oct 20. The trunk became branch 0.12. Seems I have forgotten to include the change in the announcement. And I forgot to put the date in today releases. I need to write down the checklist. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Markus G. <m.g...@gm...> - 2010-01-08 17:58:40
|
Hmm, I just diffed 0.12.0 with 0.12.1. I saw the 'ascii' change and changes in Postgres and Firebird Connection, but either I overlooked it, or there is no change regarding the cache culling algorithm. Are you sure it made it into the release? Kind regards, Markus |
From: Oleg B. <ph...@ph...> - 2010-01-08 13:15:49
|
Hello! I'm pleased to announce version 0.12.1, a bugfix release of branch 0.12 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.12.1 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.12.0 ----------------- * The cache culling algorithm was enhanced to eliminate memory leaks by removing references to dead objects; tested on a website that runs around 4 million requests a day. * Fixed a bug in col.py and dbconnection.py - if dbEncoding is None suppose it's 'ascii'. * Fixed three bugs in PostgresConnection. * Fixed a bug in FirebirdConnection. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-01-08 13:15:46
|
Hello! I'm pleased to announce version 0.11.3, a minor bugfix release of 0.11 branch of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.11.3 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.11.2 ----------------- * The cache culling algorithm was enhanced to eliminate memory leaks by removing references to dead objects; tested on a website that runs around 4 million requests a day. * Fixed a bug in col.py and dbconnection.py - if dbEncoding is None suppose it's 'ascii'. * Fixed a bug in FirebirdConnection. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-01-06 15:47:45
|
On Sun, Jan 03, 2010 at 02:32:06PM +0100, Davide Alberani wrote: > File > "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/postgres/pgconnection.py", > line 139, in makeConnection > conn.query("SET client_encoding TO %s" % dbEncoding) > AttributeError: 'psycopg2._psycopg.connection' object has no attribute > 'query' Fixed in the revisions 4067, 4068 (branch 0.12 and the trunk.) Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-01-03 14:16:08
|
On Sun, Jan 03, 2010 at 02:32:06PM +0100, Davide Alberani wrote: > conn.query("SET client_encoding TO %s" % dbEncoding) > AttributeError: 'psycopg2._psycopg.connection' object has no attribute > 'query' The bug has already been reported in the SF tracker. I will fix it RSN. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Davide A. <dav...@gm...> - 2010-01-03 13:54:08
|
I'm probably missing something very simple. :-) SQLObject from the SVN (but also 0.12), psycopg2 2.0.13, Python 2.5, Postgresql 8.4.2 on a Debian sid. Test code: =================================================== from sqlobject import * connection = connectionForURI('postgres://root:q1w2e3@localhost /imdb?charset=UTF-8') class TestTableName(SQLObject): testColName = StringCol() TestTableName.setConnection(connection) TestTableName.createTable(True) =================================================== Error: =================================================== Traceback (most recent call last): File "./pino", line 13, in <module> TestTableName.createTable(True) File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/main.py", line 1404, in createTable if ifNotExists and cls.tableExists(connection=conn): File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/main.py", line 1378, in tableExists return conn.tableExists(cls.sqlmeta.table) File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/postgres/pgconnection.py", line 191, in tableExists % self.sqlrepr(tableName)) File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/dbconnection.py", line 392, in queryOne return self._runWithConnection(self._queryOne, s) File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/dbconnection.py", line 260, in _runWithConnection conn = self.getConnection() File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/dbconnection.py", line 271, in getConnection conn = self.makeConnection() File "/home/da/develop/lib/python2.5/site-packages/SQLObject-0.13dev_r4066-py2.5.egg/sqlobject/postgres/pgconnection.py", line 139, in makeConnection conn.query("SET client_encoding TO %s" % dbEncoding) AttributeError: 'psycopg2._psycopg.connection' object has no attribute 'query' =================================================== Thanks in advance! -- Davide Alberani <da...@mi...> [PGP KeyID: 0x465BFD47] http://www.mimante.net/ |
From: Oleg B. <ph...@ph...> - 2009-12-31 18:01:49
|
Hi! On Thu, Dec 31, 2009 at 09:56:32AM -0700, David wrote: > I would like to add support to SQLObject for the www.rdbhost.com service. Welcome! > It seems that the scheme from an opener URI is used to select the > driver, but is not provided to that driver's constructor. For > example, the 'Pygresql' scheme will instantiate a These schemas are aliases for *schemas*. Only PostgresConnection has more than one aliases. And there is no 'pygresql' schema - it was removed in 0.12. > 'pgconnection::PostgresConnection', but the __init__ is not provided > the scheme name; a Pygresql user would have to provide an explicit > backend parameter to identify the Pygresql api module. I suggest that The 'backend' parameter selects a *DB API driver*. I.e., you can select psycopg2, psycopg1 or pygresql driver regardless of the schema. > dbconnection.py be modified to pass a 'scheme' parameter to the > constructors, where it would appear as part of the **kw param. A Connection class knows it's name via cls.dbName. All Connection classes except for PostgresConnection have one alias that is exactly the same as dbName. PostgresConnection has 2 aliases, but dbName is 'postgres'. If you want to change the schema probably it's best to create a new Connection class. Inherit it from PostgresConnection and redefine its dbName. > In the pgconnection init, the self.use_dsn parameter is set, and then > the self.dsn_dict and self.dsn are both created. Why are those two > built, when a dsn string is already available? The makeConnection > method uses only the self.dsn or only the self.dsn_dict, depending on > self.use_dsn. DSN strings is a rather old concept. I maintain it just in case, but I use dsn_dict and I think it's te preferred way. > What is the preferred tool for patch-making under WinXP? No idea. I develop on Linux. > Are there preconditions for adding a new database to SQLObject? License. SQLObject is LGPL-licensed. A code you want to add to SQLObject itself must be LGPL-licensed. External code (DB API drivers not included into the SQLObject code base) doesn't matter. PS. Happy New Year to all! Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: David <dvk...@gm...> - 2009-12-31 16:56:41
|
I would like to add support to SQLObject for the www.rdbhost.com service. Rdbhost provides Postgresql databases via web-service. We have a DB API 2 interface module, called 'Rdbhdb', to facilitate using our hosted databases from Python, and I would like to provide 'drop-in' support for SQLObject. In that pursuit, I have a suggestion and a question or two: It seems that the scheme from an opener URI is used to select the driver, but is not provided to that driver's constructor. For example, the 'Pygresql' scheme will instantiate a 'pgconnection::PostgresConnection', but the __init__ is not provided the scheme name; a Pygresql user would have to provide an explicit backend parameter to identify the Pygresql api module. I suggest that dbconnection.py be modified to pass a 'scheme' parameter to the constructors, where it would appear as part of the **kw param. In the pgconnection init, the self.use_dsn parameter is set, and then the self.dsn_dict and self.dsn are both created. Why are those two built, when a dsn string is already available? The makeConnection method uses only the self.dsn or only the self.dsn_dict, depending on self.use_dsn. What is the preferred tool for patch-making under WinXP? Are there preconditions for adding a new database to SQLObject? Thank you, David -- dk...@tr... Rdbhost -> SQL databases as a webservice [www.rdbhost.com] |
From: Oleg B. <ph...@ph...> - 2009-12-20 15:41:20
|
Hi! On Fri, Dec 18, 2009 at 01:19:25AM +0100, Petr Jake?? wrote: > File > "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/firebird/firebirdconnection.py", > line 120, in _queryAddLimitOffset > match = cls.limit_re.match(query) > AttributeError: class FirebirdConnection has no attribute 'limit_re' This is the patch that I think fixes the problem: Index: firebirdconnection.py =================================================================== --- firebirdconnection.py (revision 4047) +++ firebirdconnection.py (working copy) @@ -10,6 +10,8 @@ dbName = 'firebird' schemes = [dbName] + limit_re = re.compile('^\s*(select )(.*)', re.IGNORECASE) + def __init__(self, host, db, user='sysdba', password='masterkey', autoCommit=1, dialect=None, role=None, charset=None, **kw): @@ -18,8 +20,6 @@ import kinterbasdb self.module = kinterbasdb - self.limit_re = re.compile('^\s*(select )(.*)', re.IGNORECASE) - self.host = host self.db = db self.user = user Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2009-12-18 09:35:08
|
On Fri, Dec 18, 2009 at 01:19:25AM +0100, Petr Jake?? wrote: > File > "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/firebird/firebirdconnection.py", > line 120, in _queryAddLimitOffset > match = cls.limit_re.match(query) > AttributeError: class FirebirdConnection has no attribute 'limit_re' I'll look at it. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Petr J. <pet...@tp...> - 2009-12-18 00:46:41
|
Hi, I am trying to use the limit(num) method. http://www.sqlobject.org/SelectResults.html For the SQLite everything works as expected. For the Firebird database I am getting following error: Traceback (most recent call last): File "testSqlObject.py", line 55, in <module> for r in os: File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/sresults.py", line 179, in __iter__ return iter(list(self.lazyIter())) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/sresults.py", line 187, in lazyIter return conn.iterSelect(self) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/dbconnection.py", line 395, in iterSelect select, keepConnection=False) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/dbconnection.py", line 631, in __init__ self.query = self.dbconn.queryForSelect(select) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/dbconnection.py", line 409, in queryForSelect return self.sqlrepr(select.queryForSelect()) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/dbconnection.py", line 591, in sqlrepr return sqlrepr(v, self.dbName) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/converters.py", line 211, in sqlrepr return reprFunc(db) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/sqlbuilder.py", line 677, in __sqlrepr__ select = dbConnectionForScheme(db)._queryAddLimitOffset(select, start, end) File "/usr/lib/python2.5/site-packages/SQLObject-0.10.1-py2.5.egg/sqlobject/firebird/firebirdconnection.py", line 120, in _queryAddLimitOffset match = cls.limit_re.match(query) AttributeError: class FirebirdConnection has no attribute 'limit_re' Adding the line : cls.limit_re = re.compile('^\s*(select )(.*)', re.IGNORECASE) before the line: match = cls.limit_re.match(query) in the method _queryAddLimitOffset before in the file firebirdconnection.py solves the problem. I am not a Python guru and I am sure this is not a "high-level" solution. Oleg surely knows how to patch it properly :D Regards Petr |
From: Oleg B. <ph...@ph...> - 2009-12-11 09:49:40
|
On Fri, Dec 11, 2009 at 08:54:16AM +0200, Tom Coetser wrote: > And your suspicion was correct :-) The stable version in Debian Lenny seems to > be formencode 1.0.1, but updating to 1.2 seems to have fixed the problem. SQLObject's setup.py list requirement "FormEncode>=1.1.1", and I think the bugfix I made between 1.1.0 and 1.1.1 is related to the problem. If you ran setup.py install it should upgrade FormEncode automatically, shouldn't it? I use Debian too, but I have to install a lot of software manually, especially Python modules. Debian "stable" is too stable (and I don't have time to upgrade to "testing" now). Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tom C. <su...@ic...> - 2009-12-11 06:53:23
|
On Thursday 10 December 2009 23:56:51 Oleg Broytman wrote: > On Thu, Dec 10, 2009 at 11:18:33PM +0200, Tom Coetser wrote: > > >>> vt.foo(name=None) > > > > raise Invalid(self.message('empty', state), value, state) > > formencode.api.Invalid: Please enter a value > > foo(name=None) raises > > raise Invalid(self.message('empty', state), value, state) > formencode.api.Invalid: The name may not be empty. > > for me. I suspect you are using old buggy version of FormEncode. And your suspicion was correct :-) The stable version in Debian Lenny seems to be formencode 1.0.1, but updating to 1.2 seems to have fixed the problem. Thanks very much. Cheers, Tom |
From: Oleg B. <ph...@ph...> - 2009-12-10 21:57:09
|
On Thu, Dec 10, 2009 at 11:18:33PM +0200, Tom Coetser wrote: > >>> vt.foo(name=None) > raise Invalid(self.message('empty', state), value, state) > formencode.api.Invalid: Please enter a value foo(name=None) raises raise Invalid(self.message('empty', state), value, state) formencode.api.Invalid: The name may not be empty. for me. I suspect you are using old buggy version of FormEncode. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tom C. <su...@ic...> - 2009-12-10 21:22:14
|
Hi All, I am using the field validator option to auto validate certain fields, and return more meaningful error messages than the default ones returned by formencode. It seems that there is a problem with changing some of the messages though. Given this sample file : ~~~~~~~~~~~~~ validatorTest.py ~~~~~~~~~~~~~~~~~~~~ from sqlobject import * from formencode import validators, Invalid __connection__ = "sqlite:/:memory:" validName = validators.String(not_empty=True, min=5, messages={'empty': 'The name may not be empty.', 'noneType': 'The name is None', 'tooShort': 'The name is too short', } ) class foo(SQLObject): name = StringCol(validator=validName) foo.createTable() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When passing a value of None for 'name' when creating a new foo, this is the message raised with the Invalid exception: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> import validatorTest as vt >>> vt.foo(name=None) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1223, in __init__ self._create(id, **kw) File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1268, in _create self.set(**kw) File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1086, in set value = to_python(dbValue, self._SO_validatorState) File "/usr/lib/python2.5/site-packages/formencode/api.py", line 370, in to_python raise Invalid(self.message('empty', state), value, state) formencode.api.Invalid: Please enter a value >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I would have expected to see the message "The name is None". Also, when passing name as the empty string, the message is still "Please enter a value" : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> vt.foo(name='') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1223, in __init__ self._create(id, **kw) File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1268, in _create self.set(**kw) File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1086, in set value = to_python(dbValue, self._SO_validatorState) File "/usr/lib/python2.5/site-packages/formencode/api.py", line 370, in to_python raise Invalid(self.message('empty', state), value, state) formencode.api.Invalid: Please enter a value >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Again, the message expected was: "The name may not be empty." But, when passing name as a string shorter than 5 chars, the correct message is used: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> vt.foo(name='123') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1223, in __init__ self._create(id, **kw) File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1268, in _create self.set(**kw) File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 1086, in set value = to_python(dbValue, self._SO_validatorState) File "/usr/lib/python2.5/site-packages/formencode/api.py", line 381, in to_python value = tp(value, state) File "/usr/lib/python2.5/site-packages/formencode/compound.py", line 57, in _to_python to_python) File "/usr/lib/python2.5/site-packages/formencode/compound.py", line 118, in attempt_convert value = validate(validator, value, state) File "/usr/lib/python2.5/site-packages/formencode/compound.py", line 15, in to_python return validator.to_python(value, state) File "/usr/lib/python2.5/site-packages/formencode/api.py", line 378, in to_python vo(value, state) File "/usr/lib/python2.5/site-packages/formencode/validators.py", line 1086, in validate_other value, state) formencode.api.Invalid: The name is too short >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The validator seems to work correctly as shown: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> vt.validName.to_python(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/formencode/api.py", line 370, in to_python raise Invalid(self.message('empty', state), value, state) formencode.api.Invalid: The name may not be empty. >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... and ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> vt.validName.to_python('') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/formencode/api.py", line 370, in to_python raise Invalid(self.message('empty', state), value, state) formencode.api.Invalid: The name may not be empty. >>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Anyone have any ideas why the old default formencode messages are used for an empty or None value when specifying new messages for those conditions? TIA, Tom |
From: Oleg B. <ph...@ph...> - 2009-12-07 18:28:34
|
Hi! On Mon, Dec 07, 2009 at 06:41:54PM +0200, Tom Coetser wrote: > The problem is that when creating a new object based on an > InheritableSQLObject class, and the creation of the child object fails after > a new parent was created, the parent record will remain in the database > without the relevant child. A valid concern, sure. I never stumbled upon the problem because I always use transactions, and on any exception I just ABORT the transaction; on ABORT the DB removes the half created parent. > I'm attaching a patch as a possible fix for this Thank you! > - super(InheritableSQLObject, self)._create(id, **kw) > + # TC: Create this record and catch all exceptions in order to destroy > + # TC: the parent if the child can not be created. > + try: > + super(InheritableSQLObject, self)._create(id, **kw) > + except: > + # TC: If we are the child, destroy the parent > + if self.sqlmeta.parentClass: > + self._parent.destroySelf() > + self._parent = None > + # TC: Reraise the original exception > + raise > + The patch looks rather simple and straightforward. I'll test it. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tom C. <su...@ic...> - 2009-12-07 17:35:37
|
Hi all, I am doing some tests with InheritableSQLobject and have run into a problem which I hope to get some feedback on. The problem is that when creating a new object based on an InheritableSQLObject class, and the creation of the child object fails after a new parent was created, the parent record will remain in the database without the relevant child. Here is a short example: ~~~~~~~~~~ file: inheritTest3.py ~~~~~~~~~~~~ from sqlobject import * from sqlobject.inheritance import InheritableSQLObject __connection__ = "sqlite:/:memory:" class Vehicle(InheritableSQLObject): vid = StringCol(notNone=True, default=None, unique=True) wheels = IntCol() class Bicycle(Vehicle): seats = IntCol(notNone=True, default=None) class Car(Vehicle): doors = IntCol(notNone=True, default=None) def createTables(): Vehicle.createTable() Bicycle.createTable() Car.createTable() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is a sample session showing the problem when trying to create a bicycle but only supplying the args required for the Vehicle part of the object: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In [1]: from inheritTest3 import * In [2]: createTables(True) In [3]: b = Bicycle(vid="id1", wheels=4) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (22, 0)) --------------------------------------------------------------------------- IntegrityError Traceback (most recent call last) /home/tomc/mobilereporter.repo/main/app/<ipython console> in <module>() /usr/lib/python2.5/site-packages/sqlobject/main.pyc in __init__(self, **kw) 1221 id = None 1222 -> 1223 self._create(id, **kw) 1224 .... snipping lots of traceback parts ............ /usr/lib/python2.5/site-packages/sqlobject/sqlite/sqliteconnection.pyc in _executeRetry(self, conn, cursor, query) 187 raise DuplicateEntryError(msg) 188 else: --> 189 raise IntegrityError(msg) 190 except self.module.InternalError, e: 191 raise InternalError(ErrorMessage(e)) IntegrityError: bicycle.seats may not be NULL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you now supply all required args for the bicycle, using the same field values for the vid and wheels as before, a duplicate entry error is raised: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In [4]: b = Bicycle(vid="id1", wheels=4, seats=2) ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (22, 0)) --------------------------------------------------------------------------- DuplicateEntryError Traceback (most recent call last) /home/tomc/mobilereporter.repo/main/app/<ipython console> in <module>() /usr/lib/python2.5/site-packages/sqlobject/main.pyc in __init__(self, **kw) 1221 id = None 1222 -> 1223 self._create(id, **kw) 1224 1225 for func in post_funcs: .... snipping lots of traceback parts ............ /usr/lib/python2.5/site-packages/sqlobject/sqlite/sqliteconnection.pyc in _executeRetry(self, conn, cursor, query) 185 msg = ErrorMessage(e) 186 if msg.startswith('column') and msg.endswith('not unique'): --> 187 raise DuplicateEntryError(msg) 188 else: 189 raise IntegrityError(msg) DuplicateEntryError: column vid is not unique ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The duplicate entry is because of the parent vehicle record was created when the first bicycle creation failed: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In [5]: q = "SELECT * from vehicle" In [6]: Vehicle._connection.queryAll(q) Out[6]: [(1, 'id1', 4, 'Bicycle')] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So, the problem is that if a new child object is created, but fails after the parent has been created, the parent is left in tact in the database. I'm attaching a patch as a possible fix for this, but I am not sure under which other circumstances this patch will cause other problems. Maybe a flag is needed inside the block that creates the child (parentCreatedHere=True), and only if this flag is set, should the parent be deleted in exception if the child creation failed? I would appreciate if someone with more insight into this can look at the patch an modify where neccessary. BTW: This patch is against SQLObject 0.11.0. Cheers, Tom |
From: Oleg B. <ph...@ph...> - 2009-11-27 10:29:01
|
On Thu, Nov 26, 2009 at 10:19:24PM -0500, inf...@uc... wrote: > Hi , first of all sorry for my english, I speak Spanish, but I am working with SQLObject > and I am a newbie, Welcome! > and I dont know how to make a relation among 3 tables M:M Probably you need 3 separate relations - table1<->table2, table2<->table3, table1<->table3. What SQL queries do you have in mind? I must say in advance that high-level API in SQLObject doesn't allow any query to be expressed in SQLObject's objects, but there is medium-level API that allows you to execute any SQL query and get back the list of lists of results. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: <inf...@uc...> - 2009-11-27 03:37:39
|
Hi , first of all sorry for my english, I speak Spanish, but I am working with SQLObject and I am a newbie, and I dont know how to make a relation among 3 tables M:M Thanks -- Participe en Universidad 2010, del 8 al 12 de febrero del 2010 La Habana, Cuba http://www.universidad2010.cu http://www.universidad2010.com |
From: Daniel F. <fet...@go...> - 2009-11-19 23:25:41
|
>> > Absolute crazy SQL, both the idea and the code: >> > http://code.openark.org/blog/mysql/sql-pie-chart >> > >> > Not related to SQLObject or even Python, but it's so crazy I cannot >> > resist. (-: >> >> Is it portable to all backends sqlobject supports? :) > > If I knew... Actually, I didn't recognize the SQL dialect used. > There is 'mysql' in the URL, but I doubt it is really MySQL. >From the output it also seems to me that it is mysql, actually I am pretty certain it is. Would love to do this in sqlite :) Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-11-19 17:05:53
|
On Thu, Nov 19, 2009 at 06:00:02PM +0100, Daniel Fetchinson wrote: > > Absolute crazy SQL, both the idea and the code: > > http://code.openark.org/blog/mysql/sql-pie-chart > > > > Not related to SQLObject or even Python, but it's so crazy I cannot > > resist. (-: > > Is it portable to all backends sqlobject supports? :) If I knew... Actually, I didn't recognize the SQL dialect used. There is 'mysql' in the URL, but I doubt it is really MySQL. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Daniel F. <fet...@go...> - 2009-11-19 17:00:13
|
> Absolute crazy SQL, both the idea and the code: > http://code.openark.org/blog/mysql/sql-pie-chart > > Not related to SQLObject or even Python, but it's so crazy I cannot > resist. (-: Is it portable to all backends sqlobject supports? :) Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-11-19 14:02:34
|
Absolute crazy SQL, both the idea and the code: http://code.openark.org/blog/mysql/sql-pie-chart Not related to SQLObject or even Python, but it's so crazy I cannot resist. (-: Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |