Hi,

I'm using web2py as a restful api, and model has record_versioning and 
auth.signature enabled.

db.define_table('article',
    Field('title', 'string', length=1024, required=True, unique=True),
    Field('slug', 'string', length=1024, required=True, unique=True),
    Field('body', 'text', required=True),
    Field('excerpt', 'text', required=True),
    Field('categories', 'list:reference category', required=True),
    Field('tags', 'list:reference tag', required=True),
    Field('images', 'list:reference image'),
    Field('description', 'text', required=True),
    Field('keywords', 'list:string', required=True),
    Field('is_active','boolean', writable=False, readable=False, default=
True),
    auth.signature
    , format='%(title)s')

db.article.categories.requires=IS_IN_DB(db, db.category.id, db.category.
_format, multiple=True)
db.article.tags.requires=IS_IN_DB(db, db.tag.id, db.tag._format, multiple=
True)
db.article.images.requires=IS_EMPTY_OR(IS_IN_DB(db, db.image.id, db.image.
_format, multiple=True))



db.article._enable_record_versioning()

And in my restful PUT method I'm updating record this way.

def PUT(table_name,record_id,**vars):
    ...
    result = db(db[table_name]._id==record_id).update(**vars)
    ...



Its working well so far if I modify all fields, or if I modify one list:xxx 
field type plus any other "plain" field. However if I only add one item to 
any list:xxxx field types, for example adding new keyword to the list, the 
update crashes with the following exception:

Traceback (most recent call last):
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/applications/coders/controllers/api.py"
, line 79, in PUT
    result = db(db[tbn]._id==record_id).update(**vars)
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/objects.py"
, line 2054, in update
    if any(f(self,update_fields) for f in table._before_update):
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/objects.py"
, line 2054, in <genexpr>
    if any(f(self,update_fields) for f in table._before_update):
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/objects.py"
, line 393, in <lambda>
    archive_record(qset, fs, db[an], cn))
  File 
"/mnt/dades/backup/dades/home/aposai/clients/frameworks/web2py/gluon/packages/dal/pydal/helpers/methods.py"
, line 95, in archive_record
    if fields[k] != v:
KeyError: 'id'



I don't know if it's a bug or if I'm doing something wrong or missed 
something, etc... Can you give me some light please?

Thank you! (and sorry for my english...)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to