From lists at st.imul.us Thu Apr 1 03:16:08 2004 From: lists at st.imul.us (Charles Brandt) Date: Wed Mar 31 15:25:12 2004 Subject: [orm-devel] weird bug? References: <014101c413e9$ceaf7710$2a01a8c0@marge><16484.34725.202034.843251@bubbles.tux4web.de><005d01c41515$73fbb9f0$2a01a8c0@marge><16486.39955.120435.264889@bubbles.tux4web.de><012f01c416c6$90757910$2a01a8c0@marge> <16490.36447.896290.877111@bubbles.tux4web.de> Message-ID: <017301c41786$e9b33970$2a01a8c0@marge> I'm encountering some strange behavior with the latest CVS version. I think the same problem is manifesting itself in a few different areas, but I've come up with a somewhat concise example of what throws the error for me. (something with the initializaton of a selected relational column?) Note that the only difference between the two test scripts is the order of assignment. I'm going to keep investigating, but if anyone else has a quick answer I'd love to hear it! :) -Charles. I have a MapItem that I'm using as the basis for a persistent dictionary class. The key is a unique string, and the value is a one2one relation with another dbclass (StickySession): class MapItem(dbclass): tableName = "map_items" columns = { "id" : autoincrement(), "dvalue" : one2one(StickySession, columnName="dvalue"), "dkey" : varchar() } class StickySession(dbclass): tableName = "sticky_sessions" columns = { "id" : autoincrement(), "sid" : varchar(), "remote_address" : varchar(), "creation_time" : datetime(), "user_ref" : integer(), "atime" : datetime() } ########################CODE1############################# items = conn.select(MapItem, dkey="sam").fetchall() if items: for item in items: conn.delete(item) ### test new item creation: item = MapItem(dkey="sam") conn.insert(item) print "INSERTED ITEM:" print item s_item = conn.select(MapItem, dkey='sam').fetchone() print "\n\nSELECTED ITEM:" print s_item item.dvalue = my_s item.dvalue = my_s2 s_item.dvalue = my_s s_item.dvalue = my_s2 ########################OUTPUT1############################# DELETE FROM map_items WHERE id=19 INSERT INTO map_items (dkey) VALUES ('sam') SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID() INSERTED ITEM: oid=1 dvalue= id=20L dkey='sam')> SELECT map_items.dvalue, map_items.id, map_items.dkey FROM map_items WHERE map_items.dkey='sam' SELECTED ITEM: oid=1 dvalue= id=20L dkey='sam')> UPDATE map_items SET dvalue=NULL WHERE dvalue=1 UPDATE map_items SET dvalue=1 WHERE id=20 UPDATE map_items SET dvalue=NULL WHERE dvalue=2 UPDATE map_items SET dvalue=2 WHERE id=20 UPDATE map_items SET dvalue=NULL WHERE dvalue=1 UPDATE map_items SET dvalue=1 WHERE id=20 UPDATE map_items SET dvalue=NULL WHERE dvalue=2 UPDATE map_items SET dvalue=2 WHERE id=20 ########################CODE2############################# items = conn.select(MapItem, dkey="sam").fetchall() if items: for item in items: conn.delete(item) ### test new item creation: item = MapItem(dkey="sam") conn.insert(item) print "INSERTED ITEM:" print item item.dvalue = my_s item.dvalue = my_s2 s_item = conn.select(MapItem, dkey='sam').fetchone() print "\n\nSELECTED ITEM:" print s_item s_item.dvalue = my_s s_item.dvalue = my_s2 ########################OUTPUT2############################# SELECT map_items.dvalue, map_items.id, map_items.dkey FROM map_items WHERE map_items.dkey='sam' DELETE FROM map_items WHERE id=20 INSERT INTO map_items (dkey) VALUES ('sam') SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID() INSERTED ITEM: oid=1 dvalue= id=21L dkey='sam')> UPDATE map_items SET dvalue=NULL WHERE dvalue=1 UPDATE map_items SET dvalue=1 WHERE id=21 UPDATE map_items SET dvalue=NULL WHERE dvalue=2 UPDATE map_items SET dvalue=2 WHERE id=21 SELECT map_items.dvalue, map_items.id, map_items.dkey FROM map_items WHERE map_items.dkey='sam' SELECTED ITEM: oid=1 dvalue= id=21L dkey='sam')> Traceback (most recent call last): File "session_test.py", line 67, in ? s_item.dvalue = my_s File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site -packages/orm/dbclass.py", line 356, in __setattr__ self._data[name].set(value) File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site -packages/orm/relationships.py", line 305, in set self.ds().execute( AttributeError: 'NoneType' object has no attribute 'relation' From diedrich at tux4web.de Fri Apr 23 20:35:55 2004 From: diedrich at tux4web.de (Diedrich Vorberg) Date: Fri Apr 23 13:33:01 2004 Subject: [orm-devel] Re: Firebird and 0.15 In-Reply-To: <40854DA1.4060103@free.fr> References: <40854DA1.4060103@free.fr> Message-ID: <16521.25099.222508.684010@lisa.local.> Hi Werner, >1. couldn't pass debug keyword to the connection > self.ds = datasource(('''adapter=firebird database=%s > user=user password=pw charset=ISO8859_1 >debug=1''') > % dbfilename) I see, there was an error in datasource.py, line 259. I confused kwargs and params. > Will change it along the lines you use in the examples Should be no need anymore, I'll upload 0.16. >2. can you add the following to orm.firebird.datasource.py in __init__ > # Kinterbasdb and Firebird only needs the following - WFB Dec 2003 > self.escapedChars = [("'", "''")] no prob. >I also get the impression that things are a bit slower then they were, >but this is just an impression, I have not done any kind of benchmarking. Hm... I'd be surprised if orm had anything to do with this. The performance loss compared to writing SQL by hand should be minuscule. There is simply no need for "expensive" computations anywhere in orm. >Testing so far was just to get to have things run without any obvious >errors (like exceptions etc). Will over the next few days try and do >more serious testing. Great! Thank you very much for your efforts! Diedrich -- Diedrich Vorberg .---. / \ http://tux4web.de Tel: 02302 425269 / \ ((__-^^-,-^^-__)) \.O-O./ `-_---' `---_-' "Unix is simple, but it takes a genius /`\_/`\ `--|o` 'o|--' to understand the simplicity." // _ \\ \ ` / - Dennis Ritchie | \ )|_ ): :( /`\_`> <_/ \ :o_o: Associate Member of the FSF #1245 \__/'---'\__/ "-"