Which web2py version? If trunk, please open a ticket.

On Friday, 18 May 2012 03:11:18 UTC-5, Johann Spies wrote:
>
> I get the error in the subject line and I do not have any idea why.
>
> I have the following model (shortened):
>  db.define_table('doccenter',
>                         Field('doc_nr',
>                               type = 'string',
>                               length = 50),                               
>             
>                         Field('location'),                        Field(
> 'category'),
>                         akb_signature_uuid,
>                         Field('loc_id', 'bigint'),
>                         Field('cat_id', 'bigint')
>                         )
>
> The following terminal session illustrates the problem
>
> In [3]: x = 1
>
> In [4]: y = 1
>
> In [5]: rid = 1
>
> In [6]: db.doccenter[rid] = dict(loc_id= x, cat_id = y)
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last
> )
> /home/js/web2py/applications/nakb/models/menu.py in <module>()
> ----> 1 db.doccenter[rid] = dict(loc_id= x, cat_id = y)
>
> /home/js/web2py/gluon/dal.pyc in __setitem__(self, key, value)
>    7058                 self.insert(**self._filter_fields(value))
>    7059             elif self._db(self._id == key)\
> -> 7060                     .update(**self._filter_fields(value)) is None:
>    7061                 raise SyntaxError, 'No such record: %s' % key
>    7062         else:
>
> /home/js/web2py/gluon/dal.pyc in update(self, **update_fields)
>    8018         fields = table._listify(update_fields,update=True)
>    8019         if not fields: raise SyntaxError, "No fields to update"
> -> 8020         ret = self.db._adapter.update(tablename,self.query,fields)
>    8021         ret and [f(self,update_fields) for f in table.
> _after_update]
>    8022         return ret
>
> /home/js/web2py/gluon/dal.pyc in update(self, tablename, query, fields)
>    1188 
>    1189     def update(self, tablename, query, fields):
> -> 1190         sql = self._update(tablename, query, fields)
>    1191         self.execute(sql)
>    1192         try:
>
> /home/js/web2py/gluon/dal.pyc in _update(self, tablename, query, fields)
>    1184             sql_w = ''
>    1185         sql_v = ','.join(['%s=%s' % (field.name, self.expand(value
> , field.type)) \
> -> 1186                               for (field, value) in fields])
>    1187         return 'UPDATE %s SET %s%s;' % (tablename, sql_v, sql_w)
>    1188 
>
> /home/js/web2py/gluon/dal.pyc in expand(self, expression, field_type)
>    1127                 return '(%s)' % expression.op
>    1128         elif field_type:
> -> 1129             return str(self.represent(expression,field_type))
>    1130         elif isinstance(expression,(list,tuple)):
>    1131             return ','.join(self.represent(item,field_type) foritem 
> in expression)
>
> /home/js/web2py/gluon/dal.pyc in represent(self, obj, fieldtype)
>    2332 #                 raise SyntaxError, 'Invalid field type %s' 
> %fieldtype
>
>    2333             return value
> -> 2334         return BaseAdapter.represent(self, obj, fieldtype)
>    2335 
>    2336 
>
> /home/js/web2py/gluon/dal.pyc in represent(self, obj, fieldtype)
>    1508             elif isinstance(obj, (Row, Reference)):
>    1509                 return str(obj['id'])
> -> 1510             return str(int(obj))
>    1511         elif fieldtype == 'double':
>    1512             return repr(float(obj))
>
> TypeError: int() argument must be a string or a number, not 'Table'
>
> Can somebody explain to me what is going on here?
>
> Regards
> Johann
>
>

Reply via email to