I am having a problem using a list:reference field with a MongoDB database, 
like so:
db.define_table('page',
    ...
    Field('id_moderator','list:reference auth_user',default=auth.user_id),
    ...
    )


When I insert a record into this table with a list for the id_moderator 
field, like so:
db.page.insert(...,id_moderator=[id_owner],...)

I get the error:  "object_id argument must be of type ObjectId or an 
objectid representable integer"

because the MongoDBAdapter is not expecting the field's value to be a 
list.  Is this not the correct way to set list:reference type fields?

By the way, I can get around this by changing this line in MongoDBAdapter's 
insert function in dal.py:
values[fieldname] = self.object_id(v)

to this:
if isinstance(v,list):
    values[fieldname] = [self.object_id(x) for x in v]
else:
    values[fieldname] = self.object_id(v)

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to