bug. Fixed in trunk. Sorry it took so long.

On Nov 8, 10:38 pm, "richard.ree" <[email protected]> wrote:
> I want to upload a file and store it in a blob field:
>
> db.define_table(
>     "data",
>     Field("citation", "string", required=True, notnull=True),
>     Field("datafile", "upload", uploadfield="data"),
>     Field("data", "blob"),
>     )
>
> But if I insert a record (through SQLFORM or admin) but leave the
> datafile field empty, i.e., I input a citation but not a file, I get
> this error:
>
> web2py Version 1.88.2 (2010-10-29 23:04:43)
>
> Traceback (most recent call last):
>   File "/home/rree/web2py/gluon/restricted.py", line 188, in
> restricted
>     exec ccode in environment
>   File "/home/rree/web2py/applications/mytest/controllers/
> appadmin.py", line 410, in <module>
>   File "/home/rree/web2py/gluon/globals.py", line 96, in <lambda>
>     self._caller = lambda f: f()
>   File "/home/rree/web2py/applications/mytest/controllers/
> appadmin.py", line 125, in insert
>     if form.accepts(request.vars, session):
>   File "/home/rree/web2py/gluon/sqlhtml.py", line 1105, in accepts
>     value = fields[fieldname]
> KeyError: 'data'
>
> How to make the upload field optional?
>
> Thanks
> -Rick

Reply via email to