[orm-devel] Error in datasource.py ?

Mike Watkins mw@mikewatkins.net
Thu, 21 Nov 2002 08:08:52 -0800


Diedrich,

Line 382 in datasource.py appears to be missing a parameter. Somewhere, I 
can't remember where I stumbled across this, it appeared to me that "self" 
needed to be the *second* parameter there. Perhaps it will jump out at you.

With that line changed as follows:
v.append("%s=%s" % (columnName, typ.format(value, self)))

Works... but I'm not 100% sure the .format() method is actually expecting 
those two parameters.

?

Mike


  c:\dev\parlez\cms\lib\session.py in 
__setitem__(self=<cms.lib.session.SessionMapping instance at 0x0062FF38>, 
session_id='3f0ea45f7bef3c3b', session=<ParlezSession at 70c528: 
3f0ea45f7bef3c3b>)
   197
   198             if session.user.id:
   199                 p = ds.select(beans.Person, id = 
session.user.id).fetchone()
   200                 ds_session.person_id = p
   201
p undefined, ds = <orm.adapters.psql.datasource.datasource instance at 
0x00641D60>, ds.select = <bound method datasource.select of 
<orm.adapters.psql.datasource.datasource instance at 0x00641D60>>, global 
beans = <module 'cms.lib.beans' from '/dev/parlez\cms\lib\beans.pyc'>, 
beans.Person = <class cms.lib.beans.Person at 0x0062DEF0>, id undefined, 
session = <ParlezSession at 70c528: 3f0ea45f7bef3c3b>, session.user = 
<cms.lib.session.UserAttributes instance at 0x0070C3F0>, session.user.id = 
1, ).fetchone undefined

  C:\Python22\lib\site-packages\orm\datasource.py in 
select(self=<orm.adapters.psql.datasource.datasource instance at 
0x00641D60>, dbclass=<class cms.lib.beans.Person at 0x0062DEF0>, 
conjunction='and', **conds={'id': 1})
   380                 else:
   381                     typ = dbclass.columns[columnName]
   382                     v.append("%s=%s" % (columnName, typ.format(value)))
   383
   384             where = string.join(v, " %s " % conjunction)
v = [], v.append = <built-in method append of list object at 0x00734D98>, 
columnName = 'id', typ = <orm.adapters.psql.columns.serial instance at 
0x0062D1D0>, typ.format = <bound method serial.format of 
<orm.adapters.psql.columns.serial instance at 0x0062D1D0>>, value = 1

TypeError: format() takes exactly 3 arguments (2 given)
       __doc__ = 'Inappropriate argument type.'
       __getitem__ = <bound method TypeError.__getitem__ of 
<exceptions.TypeError instance at 0x0073BC98>>
       __init__ = <bound method TypeError.__init__ of <exceptions.TypeError 
instance at 0x0073BC98>>
       __module__ = 'exceptions'
       __str__ = <bound method TypeError.__str__ of <exceptions.TypeError 
instance at 0x0073BC98>>
       args = ('format() takes exactly 3 arguments (2 given)',)