Hello everyone!

I am rather new to web2py so this may be an obvious thing, but please bear 
with me.

I wrote a function to update a document in my MongoDB which looks like this:

record = db(db.stuff.id == request.vars.id).select().first()
form = SQLFORM(db.stuff, record)

which works fine the first time round but on submitting the form complains 
about a TypeError, expecting a String but getting an ObjectId.
So far so good.

My fix is to:

try:
    record=db(db.stuff.id == request.vars.id).select().first()
except TypeError:
    record=db(db.stuff.id == str(request.vars.id[0])).select().first()     
   
form = SQLFORM(db.stuff, record)

but that seems rather ugly.

I could not find anything concerning this on the web, so if there is please 
point me to it.

BR
Eduard

P.S: I also thought about using onvalidate to solve that problem, but that 
did not seem to great either (although it is better regarding reusability I 
guess)

-- 

--- 
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