sqlobject-discuss Mailing List for SQLObject (Page 378)
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: <mic...@ya...> - 2004-07-09 16:22:09
|
Hi guys! I read about a patch to implement inheritance in sqlobject, but it is for 0.52 version ok? Is there a patch to 0.6 version or this version comes with this functionality automatic (I think not ´coz the test fails to me). Thanks for the attention! ===== -- Michel Thadeu Sabchuk Curitiba/PR _______________________________________________________ Yahoo! Mail agora com 100MB, anti-spam e antivírus grátis! http://br.info.mail.yahoo.com/ |
From: Jeremy F. <je...@go...> - 2004-07-07 19:22:48
|
I found that StringCol ignores the sqlType parameter, because it gets lost in StringCol's own logic for determining the column type. This caused me problems because I have a table with a BLOB field which needs to be more than 64k (the limit of TEXT on MySQL). This patch (against svn head) will always use customSQLType if it is defined. This doesn't work for Firebird databases, because it defines its own type for unbounded strings. Perhaps a better solution would be to allow the user to pass a dictionary of db-specific types? sqlobject/col.py | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) diff -puN sqlobject/col.py~stringcol-sqltype sqlobject/col.py --- SQLObject/sqlobject/col.py~stringcol-sqltype 2004-07-07 11:46:25.927588481 -0700 +++ SQLObject-jeremy/sqlobject/col.py 2004-07-07 11:47:46.660114103 -0700 @@ -297,7 +297,9 @@ class SOStringCol(SOCol): return constraints def _sqlType(self): - if not self.length: + if self.customSQLType is not None: + return self.customSQLType + elif not self.length: return 'TEXT' elif self.varchar: return 'VARCHAR(%i)' % self.length _ J |
From: Gavin <bra...@ri...> - 2004-07-05 12:34:00
|
Thanks - Gavin On Sat, 3 Jul 2004 09:54 pm, Ivo van der Wijk wrote: > On Sat, 3 Jul 2004 18:24:37 +1000, Gavin <bra...@ri...> wrote: > > How do you use AND and other such logical statements in query ie > > .select() ? > > Check the SQLBuilder documentation. Basically, you'll get constructs such > as: > > Person.select(AND(Person.q.name=='foo', Person.q.companyID==Company.id)) > > Ivo |
From: Peter W. <pw-...@te...> - 2004-07-04 17:01:12
|
Hi, I've been looking to use expiring objects from the cache and have been running into situations where they don't see to be getting expired correctly. I've put together a simple test case that in my understand should work for each of the 3 versions but fails to re-select from the db unless extra prints are put in and a reset of the variable. If any one could run the script below and either confirm that it is failing and should be working or my understanding is incorrect I'd be very appreciative. -- Regards, Peter Wilkinson. #!/usr/bin/env python2.3 from SQLObject import * conn = MySQLConnection(user='USER', db='DB', passwd='PASS') class Contact(SQLObject): _table = 'test_contact' _connection = conn firstname = StringCol() lastname = StringCol() # # version 1 - doesn't work, only selects from the db twice # print "----- 1 -----" Contact.createTable() Contact.new(firstname = 'First', lastname = 'Last') a = Contact(1) # first read b = Contact(1) # cached print "a: (First) ", a.firstname print "b: (First) ", b.firstname conn.query("update test_contact set firstname = 'Change' where id = 1") b.expire() a = Contact(1) # read again print "a: (Change) ", a.firstname # gets correct value conn.query("update test_contact set firstname = 'Another' where id = 1") b.expire() b = Contact(1) # should read again print "a: (Another) ", a.firstname # this is not correct print "b: (Another) ", b.firstname # this is not correct Contact.dropTable() # # version 2. sort of works a is out of whack at the end # print "----- 2 -----" Contact.createTable() Contact.new(firstname = 'First', lastname = 'Last') a = Contact(1) # first read b = Contact(1) # cached print "a: (First) ", a.firstname print "b: (First) ", b.firstname conn.query("update test_contact set firstname = 'Change' where id = 1") b.expire() a = Contact(1) # read again print "a: (Change) ", a.firstname # gets correct value print "b: (Change) ", b.firstname # FIX - this makes b up-to-date after the next expire conn.query("update test_contact set firstname = 'Another' where id = 1") b.expire() b = Contact(1) # should read again, making a up-to-date print "a: (Another) ", a.firstname # this is not correct print "b: (Another) ", b.firstname # gets correct value Contact.dropTable() # # version 3. works # print "----- 3 -----" Contact.createTable() Contact.new(firstname = 'First', lastname = 'Last') a = Contact(1) # first read b = Contact(1) # cached print "a: (First) ", a.firstname print "b: (First) ", b.firstname conn.query("update test_contact set firstname = 'Change' where id = 1") b.expire() a = Contact(1) # read again print "a: (Change) ", a.firstname # gets correct value print "b: (Change) ", b.firstname # gets correct value conn.query("update test_contact set firstname = 'Another' where id = 1") b.expire() b = Contact(1) # should read again, making a up-to-date a = Contact(1) # FIX - this makes a up-to-date print "a: (Another) ", a.firstname # gets correct value print "b: (Another) ", b.firstname # gets correct value Contact.dropTable() |
From: Ivo v. d. W. <vla...@gm...> - 2004-07-03 11:54:16
|
On Sat, 3 Jul 2004 18:24:37 +1000, Gavin <bra...@ri...> wrote: > How do you use AND and other such logical statements in query ie .select() > ? Check the SQLBuilder documentation. Basically, you'll get constructs such as: Person.select(AND(Person.q.name=='foo', Person.q.companyID==Company.id)) Ivo -- Drs. I.R. van der Wijk -=- Korte Leidsedwarsstraat 12 Amaze 1017 RC Amsterdam, NL -=- T +31-20-4688336 F +31-20-4688337 Zope/Plone/Content Management W http://www.amaze.nl E in...@am... Open Source Solutions W http://vanderwijk.info E iv...@am... Consultancy PGP http://vanderwijk.info/pgp |
From: Gavin <bra...@ri...> - 2004-07-03 08:25:30
|
How do you use AND and other such logical statements in query ie .select() ? - Gavin |
From: Cyril E. <cy...@de...> - 2004-07-02 12:55:04
|
Because they are 128 bits hexadecimal GUIDs prefixed by strings. This is a requirement of the application. Anyway I've made the correction in the __repr__ routine. Cyril Elkaim Karl Chen wrote: > Why not just convert the IDs to integers if they are just string > representations of integers? > > >>>>>>"Cyril" == Cyril Elkaim <cy...@de...> writes: > > Cyril> > Cyril> Hi All, I'm discovering SQLObject (SVN version). I'm > Cyril> using it with an existing database under Postgres. In > Cyril> this database all IDs are in hexadecimal so represented > Cyril> as strings. So far so good, but the SQLObject.__repr__ > Cyril> method accept integer IDs only. Every other routine in > Cyril> this class accept string IDs. > Cyril> > Cyril> Is it possible to make the correction? I can do that on > Cyril> my own machine of course but what about the SVN > Cyril> version? > |
From: Karl C. <qu...@no...> - 2004-07-01 08:36:03
|
Why not just convert the IDs to integers if they are just string representations of integers? >>>>> "Cyril" == Cyril Elkaim <cy...@de...> writes: Cyril> Cyril> Hi All, I'm discovering SQLObject (SVN version). I'm Cyril> using it with an existing database under Postgres. In Cyril> this database all IDs are in hexadecimal so represented Cyril> as strings. So far so good, but the SQLObject.__repr__ Cyril> method accept integer IDs only. Every other routine in Cyril> this class accept string IDs. Cyril> Cyril> Is it possible to make the correction? I can do that on Cyril> my own machine of course but what about the SVN Cyril> version? -- Karl 2004-07-01 01:34 |
From: Cyril E. <cy...@de...> - 2004-07-01 08:20:21
|
Hi All, I'm discovering SQLObject (SVN version). I'm using it with an existing database under Postgres. In this database all IDs are in hexadecimal so represented as strings. So far so good, but the SQLObject.__repr__ method accept integer IDs only. Every other routine in this class accept string IDs. Is it possible to make the correction? I can do that on my own machine of course but what about the SVN version? Thanks, Cyril Elkaim |
From: Akki N. <ak...@ak...> - 2004-06-28 14:26:25
|
Hi everybody! I've got a question about threadsafety: I'm getting objects of type 'dozent' from Zope and insert them into a PostgreSQL-Database via SQLObject: db = deputatsabrechnung.DeputatsDB() #getting a connection to the DB (see code below) dozenten = self.getDozentListing() #getting the dozenten from zope for dozent in dozenten: trans = db.newTransaction() # starting a new transaction table = db.getDozenten(trans) table.addDozent(dozent.UID(), dozent.getVorname(),dozent.getName(), dozent.getKuerzel(), dozent.getAnrede()) trans.commit() # ending the transaction For every dozent i'm inserting into the DB I start a new transaction: import SQLObject class DeputatsDB: def __init__(self): """Initiate a database connection""" self._conn = SQLObject.PostgresConnection('user=akki dbname=deputat') def newTransaction(self): """Open a new transaction""" return self._conn.transaction() And now my question: are the insertions into the DB thread-safe? Regards Akki Nitsch ############################################################# The freedom of meaning one thing and saying something different is not permitted. E.W. Dijkstra |
From: Dirk E. <di...@Ce...> - 2004-06-28 07:52:53
|
Hi, it would also make it easier for DBMSs like Oracle that only provide sequences in the first place. Oracle specific code for ids would be reduced to a one liner. Nice! Cheers Dirk -- Dirk J. Evers dir...@ce... NRW Graduate School in +49 (0)521/106-3793 Bioinformatics and Genome Research, CeBiTec - Center for Biotechnology University of Bielefeld, D-33594 Bielefeld, Germany |
From: Ivo v. d. W. <vla...@gm...> - 2004-06-25 18:19:00
|
On Fri, 25 Jun 2004 13:22:29 +0000 (UTC), Carroll Kong <me...@ca...> wrote: > > Using Postgresql with SQLObject (svn updated a few days ago, shouldn't matter in > this case anyway) > > I created a "writeable" view (using rules). However because the viewname is > different than the actual primary key, then my inserts fail > I ran into exactly the same problem when experimenting with views, and I ran into it recently again when I wanted to use a global sequence to get unique id's across tables (don't ask why :) I'd like a feature like this. It should probably part of the id column definition, which is not present at this moment (why can't id columns be defined explicitly?) Cheers Ivo |
From: Luke O. <lu...@me...> - 2004-06-25 14:56:41
|
Use the _registry class attribute: class Cidade(SQLObject): _registry =3D "site1" ... It's just a string identifier to group objects together - all your classes f= or a site will need to have it set. This is for the global name registry in SO, since for Joins and ForeignKeys you only specify the classes by name. - Luke Because of the need to identify classes by name when their Quoting Michel Thadeu <mic...@ya...>: > Hi guys! > > I having a problem I don=B4t know how to solve. I have tow different > sites (made in webware) and hava two different modules to access two > different database. > > The first site database was designed using the SQLObject=B4s createTable > method. I have one table called cidade and another one called estado. > The second site database was designed to another person, the database > name convention is too strange. The cidade id is not called id or > cidade_id, it is called cidaauct. So I need to specify each column=B4s > name. > > The problem is that the webware are caching the Cidade class (I think), > I have put a _cacheValues=3DFalse on the class without sucess (I put in > all class), so I think the focus is the webware. If I acess the second > site first and then the first site there is no problem, but if I try to > access the first and then the second, the column estado_id is not > found, i think when the sqlobject is trying to make the join. > > How can I specify to webware (if the problem is with webware), that > Site1.Database1.Estado is not equal Site2.Database2.Estado, or anything > like this? > > Does anyone have such problem? > > thanks for the attention, I will list the two classes code follow: > > File: Site1.Database1 > ... > __CONNECTION__=3D'mysql://...' > > class Cidade(SQLObject): > _connection=3D__CONNECTION__ > _cacheValues=3DFalse > nome=3DStringCol(length=3D50) > estado=3DForeignKey('Estado') > > class Estado(SQLObject): > _connection=3D__CONNECTION__ > _cacheValues=3DFalse > nome=3DStringCol(length=3D50) > sigla=3DStringCol(length=3D2, alternateID=3DTrue) > cidades=3DMultipleJoin('Cidade') > ... > > File: Site2.Database2 > ... > CONNECTION=3D'mysql://...' > > class Cidade(SQLObject): > _connection=3DCONNECTION > _idName=3D'codicida' > _cacheValues=3DFalse > nome=3DStringCol(dbName=3D'desccida') > estado=3DForeignKey('Estado', dbName=3D'codiesta') > > class Estado(SQLObject): > _connection=3DCONNECTION > _idName=3D'codiesta' > _cacheValues=3DFalse > nome=3DStringCol(dbName=3D'descesta') > sigla=3DStringCol(dbName=3D'siglesta', length=3D2, alternateID=3DTrue) > cidades=3DMultipleJoin('Cidade') > ... > > =3D=3D=3D=3D=3D > -- > Michel Thadeu Sabchuk > Curitiba/PR > > ______________________________________________________________________ > > Yahoo! Mail - agora com 100MB de espa=E7o, anti-spam e antiv=EDrus gr=E1ti= s! > http://br.info.mail.yahoo.com/ > > > ------------------------------------------------------- > This SF.Net email sponsored by Black Hat Briefings & Training. > Attend Black Hat Briefings & Training, Las Vegas July 24-29 - > digital self defense, top technical experts, no vendor pitches, > unmatched networking opportunities. Visit www.blackhat.com > _______________________________________________ > Webware-discuss mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webware-discuss -- The Pursuit of Counterfactual Histories |
From: <mic...@ya...> - 2004-06-25 14:08:29
|
Hi guys! I having a problem I don´t know how to solve. I have tow different sites (made in webware) and hava two different modules to access two different database. The first site database was designed using the SQLObject´s createTable method. I have one table called cidade and another one called estado. The second site database was designed to another person, the database name convention is too strange. The cidade id is not called id or cidade_id, it is called cidaauct. So I need to specify each column´s name. The problem is that the webware are caching the Cidade class (I think), I have put a _cacheValues=False on the class without sucess (I put in all class), so I think the focus is the webware. If I acess the second site first and then the first site there is no problem, but if I try to access the first and then the second, the column estado_id is not found, i think when the sqlobject is trying to make the join. How can I specify to webware (if the problem is with webware), that Site1.Database1.Estado is not equal Site2.Database2.Estado, or anything like this? Does anyone have such problem? thanks for the attention, I will list the two classes code follow: File: Site1.Database1 ... __CONNECTION__='mysql://...' class Cidade(SQLObject): _connection=__CONNECTION__ _cacheValues=False nome=StringCol(length=50) estado=ForeignKey('Estado') class Estado(SQLObject): _connection=__CONNECTION__ _cacheValues=False nome=StringCol(length=50) sigla=StringCol(length=2, alternateID=True) cidades=MultipleJoin('Cidade') ... File: Site2.Database2 ... CONNECTION='mysql://...' class Cidade(SQLObject): _connection=CONNECTION _idName='codicida' _cacheValues=False nome=StringCol(dbName='desccida') estado=ForeignKey('Estado', dbName='codiesta') class Estado(SQLObject): _connection=CONNECTION _idName='codiesta' _cacheValues=False nome=StringCol(dbName='descesta') sigla=StringCol(dbName='siglesta', length=2, alternateID=True) cidades=MultipleJoin('Cidade') ... ===== -- Michel Thadeu Sabchuk Curitiba/PR ______________________________________________________________________ Yahoo! Mail - agora com 100MB de espaço, anti-spam e antivírus grátis! http://br.info.mail.yahoo.com/ |
From: Carroll K. <me...@ca...> - 2004-06-25 13:30:45
|
Using Postgresql with SQLObject (svn updated a few days ago, shouldn't matter in this case anyway) I created a "writeable" view (using rules). However because the viewname is different than the actual primary key, then my inserts fail File "/usr/local/lib/python2.3/site-packages/sqlobject/postgres/pgconnection.py", line 62, in _queryInsertID c.execute("SELECT NEXTVAL('%s_%s_seq')" % (table, idName)) psycopg.ProgrammingError: ERROR: relation "clients_view_clients_id_seq" does not exist SELECT NEXTVAL('clients_view_clients_id_seq') clients_view is a composite of multiple tables, the actual sequence is in another table "clients", so the sequence is really clients_clients_id_seq. Can we add a simple parameter to allow arbitrary sequence names instead? Or is there some other work around? (I could wrap all of the inserts in another transaction, but for other reasons, I want to avoid doing that). |
From: Ben B. <in...@em...> - 2004-06-24 23:43:55
|
On Thu, Jun 24, 2004 at 05:29:54PM -0400, CLIFFORD ILKAY wrote: > I am trying to trap a SQL error caused by attempting to INSERT a duplicate > unique key. Here is what I have tried. > > ############# > def writeContent(self): > pr = self.writeln > newForm = self.form > if newForm.isSuccessful(): > theTelnumType = > TelnumType.byDescription(newForm.numType.value()) > if theTelnumType: > pr('''<p>There is already a Telnum Type = > '%s'</p>''' % newForm.numType.value()) > else: # not a duplicate so save > newTelnumType = TelnumType ( > description = > newForm.numType.value(), > modUserId = 'cilkay' > ) > pr('''<p>Successfully saved Telnum Type = > '%s'</p>''' % newForm.numType.value()) > else: > ############# > > So, if I already have a row in telnum_type where description = 'Home', no > problem, the code above will print out: "There is already a Telnum Type = > 'Home'". However, if there is no Telnum Type = 'Home', I now get a > SQLObjectNotFound error raised by SQLObject. If I just try to insert > without doing a test for a duplicate value, I of course get the usual SQL > error about violating a unique key constraint. How can I trap SQL errors, > not just unique key constraint violations, so that I can provide meaningful > messages to end users? You want to catch the exception (http://www.python.org/doc/current/tut/node10.html). You could either leave your test in place and catch the SQLObjectNotFound exception or skip the test and catch the psycopg.ProgrammingError when you try to insert the duplicate key. ########### try: TelnumType.byDescription(newForm.numType.value()) except SQLObjectNotFound: TelnumType.new(description = blah, ... ) pr('''<p>Successfully did some stuff</p>''') ########### I don't like that approach, as it is conceptually ugly (the exception would be the common case instead of, well, the exception) and you could accomplish the same thing more efficiently by eliminating the test and just catching the exception if you try to insert a duplicate. ########### try: TelnumType.new(description = blah, ... ) except psycopg.ProgrammingError: pr('''<p>There is already a Telnum Type = '%s'</p>''' % newForm.numType.value()) ########### Exceptions rock. -Ben -- Ben Beuchler There is no spoon. in...@em... -- The Matrix |
From: CLIFFORD I. <cli...@di...> - 2004-06-24 21:30:05
|
Hi, I am trying to trap a SQL error caused by attempting to INSERT a duplicate unique key. Here is what I have tried. ############# def writeContent(self): pr = self.writeln newForm = self.form if newForm.isSuccessful(): theTelnumType = TelnumType.byDescription(newForm.numType.value()) if theTelnumType: pr('''<p>There is already a Telnum Type = '%s'</p>''' % newForm.numType.value()) else: # not a duplicate so save newTelnumType = TelnumType ( description = newForm.numType.value(), modUserId = 'cilkay' ) pr('''<p>Successfully saved Telnum Type = '%s'</p>''' % newForm.numType.value()) else: ############# So, if I already have a row in telnum_type where description = 'Home', no problem, the code above will print out: "There is already a Telnum Type = 'Home'". However, if there is no Telnum Type = 'Home', I now get a SQLObjectNotFound error raised by SQLObject. If I just try to insert without doing a test for a duplicate value, I of course get the usual SQL error about violating a unique key constraint. How can I trap SQL errors, not just unique key constraint violations, so that I can provide meaningful messages to end users? Regards, Clifford Ilkay Dinamis Corporation 3266 Yonge Street, Suite 1419 Toronto, Ontario Canada M4N 3P6 Tel: 416-410-3326 |
From: Ian B. <ia...@co...> - 2004-06-24 20:49:12
|
Ivo van der Wijk wrote: > Ian Bicking wrote: > >> Hi. Sorry about not being involved the last couple weeks. It's been >> hard to keep up with SQLObject, mostly because I'm not actually using >> it myself at the moment. I'm trying to change that, but I have a hard >> time keeping motivated when I don't have any direct needs. >> >> But I don't mind if people hassle me about things like the wiki or >> repository. Those are both back up. Please email me directly if >> there are things that need to be done. I'll try to catch up, though >> I'm about to go out of town for a week and I won't be able to look at >> anything before then. >> > > If anyone sends improvements/patches, would you still be available > (timely) to check/add them? Or would that have to wait as well? > > I now onderstand you don't have the time / motivation to add my > suggestions - I could give it a try myself. Several people on the list have commit access, and I'm willing to give access to other people as well. People should feel particularly free to develop in a branch on the repository if they have ideas they want to experiment with or share. Anyone who is interested should email me off-list. Ian |
From: CLIFFORD I. <cli...@di...> - 2004-06-24 18:40:54
|
Hi, There has been an interesting thread over on the WebWare discussion list about how to prevent SQL injection on database queries. The subject line is "FormKit Validator question". How does SQLObject deal with this? Regards, Clifford Ilkay Dinamis Corporation 3266 Yonge Street, Suite 1419 Toronto, Ontario Canada M4N 3P6 Tel: 416-410-3326 |
From: Roberto M. C. <ze...@se...> - 2004-06-24 15:50:42
|
From: Ben B. <in...@em...> - 2004-06-24 15:33:53
|
I'm retrofitting some code to use transactions and have run into a snag: How do you pass a transaction to a table that does not have a class? Ex: class Machine(SQLObject): _cacheValue = False .... os = RelatedJoin('OsT', intermediateTable='machine_os_assoc', joinColumn='machine_id', otherColumn='os_id', addRemoveName='Os') class Os(SQLObject): _cacheValue = False .... machines = RelatedJoin('MachineT', intermediateTable='machine_os_assoc', joinColumn='os_id', otherColumn='machine_id') When I instantiate Machine, I pass "connection=trans", where "trans" is a transaction instance. For Machine, trans.rollback(), trans.commit(), and trans.begin() all work as expected. However, if I call the .addOs() method of my Machine instance, it uses the normal connection, *not* the transaction. What is the correct way to make this work? I can't just change the global __connection__ instance to be a transaction, as that would break too much existing code... Thanks! -Ben -- Ben Beuchler There is no spoon. in...@em... -- The Matrix |
From: Karl C. <qu...@no...> - 2004-06-24 11:54:56
|
I ended up writing this for myself; if anyone is interested here's the patch. Now you can do: PhoneNumber.selectBy(user=myuser) in addition to PhoneNumber.selectBy(userID=myuser.id) Index: dbconnection.py =================================================================== --- dbconnection.py (revision 1186) +++ dbconnection.py (working copy) @@ -418,12 +418,20 @@ self.sqlrepr(firstValue), self.sqlrepr(secondValue))) + def _SO_kwpair2dbpair(self, soClass, key, value): + dbcolumn = soClass._SO_columnDict.get(key) + if dbcolumn: + return (dbcolumn.dbName, self.sqlrepr(value)) + dbcolumnid = soClass._SO_columnDict.get(key+'ID') + if dbcolumnid: + return (dbcolumnid.dbName, self.sqlrepr(value.id)) + raise Exception, 'Invalid keyword "%s" to selectBy' %(key) + def _SO_columnClause(self, soClass, kw): return ' AND '.join(['%s = %s' % - (soClass._SO_columnDict[key].dbName, - self.sqlrepr(value)) - for key, value - in kw.items()]) + self._SO_kwpair2dbpair(soClass, key, value) + for key, value + in kw.items()]) def sqlrepr(self, v): return sqlrepr(v, self.dbName) -- Karl 2004-06-24 04:51 |
From: Ivo v. d. W. <iv...@am...> - 2004-06-24 08:07:56
|
Ian Bicking wrote: > Hi. Sorry about not being involved the last couple weeks. It's been > hard to keep up with SQLObject, mostly because I'm not actually using it > myself at the moment. I'm trying to change that, but I have a hard time > keeping motivated when I don't have any direct needs. > > But I don't mind if people hassle me about things like the wiki or > repository. Those are both back up. Please email me directly if there > are things that need to be done. I'll try to catch up, though I'm about > to go out of town for a week and I won't be able to look at anything > before then. > If anyone sends improvements/patches, would you still be available (timely) to check/add them? Or would that have to wait as well? I now onderstand you don't have the time / motivation to add my suggestions - I could give it a try myself. Cheers Ivo -- Drs. I.R. van der Wijk -=- Korte Leidsedwarsstraat 12 Amaze 1017 RC Amsterdam, NL -=- T +31-20-4688336 F +31-20-4688337 Zope/Plone/Content Management W http://www.amaze.nl E in...@am... Open Source Solutions W http://vanderwijk.info E iv...@am... Consultancy PGP http://vanderwijk.info/pgp |
From: Ian B. <ia...@co...> - 2004-06-24 05:55:22
|
Hi. Sorry about not being involved the last couple weeks. It's been hard to keep up with SQLObject, mostly because I'm not actually using it myself at the moment. I'm trying to change that, but I have a hard time keeping motivated when I don't have any direct needs. But I don't mind if people hassle me about things like the wiki or repository. Those are both back up. Please email me directly if there are things that need to be done. I'll try to catch up, though I'm about to go out of town for a week and I won't be able to look at anything before then. On Jun 23, 2004, at 12:06 PM, Justus Pendleton wrote: > Just wondering if you're still maintaining SQLObject? The subversion > respository has been down for a while and the wiki for even longer. I > haven't seen you post anything on the mailing list in the past couple > of weeks, either. |
From: Andrew B. <and...@pu...> - 2004-06-23 13:20:12
|
trash1 <trash1 <at> hotmail.ru> writes: [...] > about last two days I can't check svn repository: > > svn co svn://colorstudy.com/trunk/SQLObject > > svn: Berkeley DB error while opening 'nodes' table for filesystem /var/lib/subversion/repository/db: > Cannot allocate memory I'm also getting this error. -Andrew. |