request.vars.meta_description is a file (a FieldStorage object) not a string containing the bytes in the file. It contains
request.vars.meta_description.filename request.vars.meta_description.file (the input stream) So instead of db.domain.insert(meta_description=request.vars.meta_description) ###WRONG! You want db.domain.insert (meta_description=request.vars.meta_description.file.read()) ###RIGHT! Hope this makes sense. This is because you may need to retrieve the input filename and because the file size may be large than ram and you want to read a bit at the time. Massimo On Mar 2, 4:32 pm, Jim <[email protected]> wrote: > In models/db.py > > SQLField( 'meta_description','text'), > > In controllers/default.py > form=SQLFORM(db.domain,_method='POST') > form.vars=request.vars > db.domain.insert(**dict (form.vars)) > > curl -F 'name=flapdoodle.com' -F > [email protected]http://127.0.0.1:8002/init/default/add_domain > > I get domain.name=flapdoodle.com just fine. But for the description, > it starts out like this: > > FieldStorage('meta_description', 'layout.html', '<!DOCTYPE html PUBLIC > "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/ > xhtml1-strict.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" > ... > rest of layout.html > > Is there a way to get the FieldStorage out of there? I only find one > reference, on page 180 of the manual. > > PS: I have to say that the (**dict (form.vars)) is pretty freaking > cool. It lets me set up reasonable defaults in models, then use > those if information is not supplied. So I can have the value for > "public" set to default to true, for example. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

