I'm out of the loop, still at PyCon, so I won't be able to follow up on
this, but the ID field is implicit (you can set the name with _idName).
So you shouldn't have a Col('id').
That error message is kind of funny, but maybe it's just the strange
artifact from two ID's. I'll have to make an assert about that.
On Thursday, March 27, 2003, at 12:40 PM, Frank Barknecht wrote:
> Hallo,
>
> I'm trying to clean up a project and use SQLObject as DB-wrapper. The
> tables are filled and I only want to use SO in read-only mode.
>
> Now I have a probably very stupid question: How do I instantiate a new
> SQLObject given an id.
>
> I'm trying something like this, which feels natural, but doesn't work:
>
> from SQLObject import *
>
> SQLProductFields = [Col('id'), Col('description'), Col('format'),
> Col('artist'), Col('category'), Col('title'), Col('price'),
> Col('label')]
>
> class Normal(SQLObject):
> _columns = SQLProductFields
> _connection = DBConnection.MySQLConnection(host='localhost',
> db='fbar',
> user='foo', passwd='')
>
> entry=45
> n = Normal(entry) # error here!
>
> Traceback (most recent call last):
> File "SQLText.py", line 9, in ?
> n = Normal(45)
> File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", line
> 419, in __new__
> val._init(id, connection)
> File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", line
> 428, in _init
> self.id = id
> File "<string>", line 1, in <lambda>
> File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", line
> 456, in _SO_setValue
> self._SO_writeLock.acquire()
> AttributeError: 'Normal' object has no attribute '_SO_writeLock'
>
> I'm probably doing something totally wrong, but I don't get, what...
> I'm using SO from half an hour ago.
> Ciao
> --
> Frank Barknecht _ ______footils.org__
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:
> The Definitive IT and Networking Event. Be There!
> NetWorld+Interop Las Vegas 2003 -- Register today!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> _______________________________________________
> sqlobject-discuss mailing list
> sql...@li...
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
--
Ian Bicking ia...@co... http://colorstudy.com
4869 N. Talman Ave., Chicago, IL 60625 / 773-275-7241
"There is no flag large enough to cover the shame of
killing innocent people" -- Howard Zinn
|