Thread: [SQLObject] Strange behavior in sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Octav C. <och...@gm...> - 2010-09-24 01:51:40
|
Hi, I'm getting the following strange exception when using sqlobject. This occurs quite infrequently (after 1-2 mins of operation). Have you guys seen anything similar to this? File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 522, in __bootstrap_inner self.run() ..... for result in results: File "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/sresults.py", line 179, in __iter__ return iter(list(self.lazyIter())) File "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/dbconnection.py", line 665, in next obj = self.select.sourceClass.get(result[0], selectResults=result[1:], connection=self.dbconn) File "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", line 892, in get val = cls(_SO_fetch_no_create=1) TypeError: __init__() got an unexpected keyword argument '_SO_fetch_no_create Thanks, -- Octav |
From: Oleg B. <ph...@ph...> - 2010-09-24 10:06:54
|
On Thu, Sep 23, 2010 at 06:51:14PM -0700, Octav Chipara wrote: > File > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", > line 892, in get > val = cls(_SO_fetch_no_create=1) > TypeError: __init__() got an unexpected keyword argument > '_SO_fetch_no_create It seems cls here is not an SQLObject class because SQLObject.__init__ accepts any keywords arguments. You need to investigate what type is cls. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Octav C. <och...@gm...> - 2010-09-24 20:11:42
|
Thanks Oleg. BTW, is there an easy way to get attributes of an sqlobject by their name? For example, if I have a person with attributes first_name and last_name, however do i go around retrieving them. Could I do something like Person.get_attr('first_name')? Thanks, --Octav On Fri, Sep 24, 2010 at 3:06 AM, Oleg Broytman <ph...@ph...> wrote: > On Thu, Sep 23, 2010 at 06:51:14PM -0700, Octav Chipara wrote: > > File > > > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", > > line 892, in get > > val = cls(_SO_fetch_no_create=1) > > TypeError: __init__() got an unexpected keyword argument > > '_SO_fetch_no_create > > It seems cls here is not an SQLObject class because SQLObject.__init__ > accepts any keywords arguments. You need to investigate what type is cls. > > Oleg. > -- > Oleg Broytman http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2010-09-24 20:21:51
|
On Fri, Sep 24, 2010 at 01:11:13PM -0700, Octav Chipara wrote: > Thanks Oleg. BTW, is there an easy way to get attributes of an sqlobject by > their name? For example, if I have a person with attributes first_name and > last_name, however do i go around retrieving them. Could I do something like > Person.get_attr('first_name')? What is Person in your question - an SQLObject class (representing an entire SQL table) or an instance of such class (representing one row for the table)? If it's a class - you need to call Person.select() and loop over the result rows. If it's an instance - just get (or set) Person.first_name: print Person.first_name Person.first_name = 'Octav' Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Octav C. <och...@gm...> - 2010-09-24 20:18:00
|
It seems I answered my own questions. You can do this by using get_attr: p = Person(first_name='', last_name='') get_attr(p, 'first_name') # will return the first name Thanks, -- Octav On Fri, Sep 24, 2010 at 1:11 PM, Octav Chipara <och...@gm...> wrote: > Thanks Oleg. BTW, is there an easy way to get attributes of an sqlobject by > their name? For example, if I have a person with attributes first_name and > last_name, however do i go around retrieving them. Could I do something like > Person.get_attr('first_name')? > > Thanks, > --Octav > > > On Fri, Sep 24, 2010 at 3:06 AM, Oleg Broytman <ph...@ph...> wrote: > >> On Thu, Sep 23, 2010 at 06:51:14PM -0700, Octav Chipara wrote: >> > File >> > >> "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", >> > line 892, in get >> > val = cls(_SO_fetch_no_create=1) >> > TypeError: __init__() got an unexpected keyword argument >> > '_SO_fetch_no_create >> >> It seems cls here is not an SQLObject class because SQLObject.__init__ >> accepts any keywords arguments. You need to investigate what type is cls. >> >> Oleg. >> -- >> Oleg Broytman http://phd.pp.ru/ ph...@ph... >> Programmers don't die, they just GOSUB without RETURN. >> >> >> ------------------------------------------------------------------------------ >> Nokia and AT&T present the 2010 Calling All Innovators-North America >> contest >> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada >> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in >> marketing >> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store >> http://p.sf.net/sfu/nokia-dev2dev >> _______________________________________________ >> sqlobject-discuss mailing list >> sql...@li... >> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss >> > > |
From: Oleg B. <ph...@ph...> - 2010-09-24 20:25:54
|
On Fri, Sep 24, 2010 at 01:17:33PM -0700, Octav Chipara wrote: > get_attr(p, 'first_name') # will return the first name In Python (not in SQLObject) this is equivalent to p.first_name. You only need to call getattr if the name of the attribute is in a variable: attr_name = 'first_name' print getattr(p, attr_name) And, BTW, in Python the function is named getattr, not get_attr. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |