db.images includes an upload field. When using SQLFORM.factory, if you 
include an upload field, you have to specify its uploadfolder argument 
(this is not necessary with a standard SQLFORM because the uploadfolder is 
determined automatically).

Anthony

On Tuesday, March 26, 2013 5:48:58 PM UTC-4, BlueShadow wrote:
>
> Ok I guess I missed that but  I get an error at the line if 
> form.process().accepted:
>
> I changed my controler to this:
> def newImage():
>     dbtable = db.Images          #uploads table name
>     print "newImage"
>     if len(request.args):
>         records = db(dbtable.id==request.args[0]).select()
>     if len(request.args) and len(records):
>         form = SQLFORM(dbtable, records[0], deletable=True)
>     else:
>         form = SQLFORM.factory(dbtable,db.image_references)
>     if form.process().accepted:
>         print "form accepts"
>         response.flash = 'Entry for Images Database accepted,start 
> creating thumb'
>         makeThumbnail(dbtable,form.vars.id,(200,200))
>         print "thumbnail done"
>         id = db.Images.insert(**db.Images._filter_fields(form.vars))
>         print "Image table written"
>         form.vars.client=id
>         id = db.image_references.insert(**db.image_references.
> _filter_fields(form.vars))
>         print "image ref table written"
>         thisImage=db(dbtable.id==form.vars.id).select()[0]
>         calculateImagevar(thisImage)
>         
>     elif form.errors:
>         response.flash = 'Error in Form for Images Database'
>     return dict(form=form)
>
>
> I added the prints just for debugging "form accepts" is never printed
>
> Error:
>
> Traceback (most recent call last):
>   File "/home/mdipierro/make_web2py/web2py/gluon/restricted.py", line 212, in 
> restricted
>   File "F:/Website/web2py/applications/testapp/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/Movie_Alarm/controllers/default.py>,
>  line 436, in <module>
>   File "/home/mdipierro/make_web2py/web2py/gluon/globals.py", line 194, in 
> <lambda>
>   File "/home/mdipierro/make_web2py/web2py/gluon/tools.py", line 2971, in f
>   File "F:/Website/web2py/applications/testapp/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/Movie_Alarm/controllers/default.py>,
>  line 306, in newImage
>   File "/home/mdipierro/make_web2py/web2py/gluon/html.py", line 2185, in 
> process
>   File "/home/mdipierro/make_web2py/web2py/gluon/html.py", line 2124, in 
> validate
>   File "/home/mdipierro/make_web2py/web2py/gluon/sqlhtml.py", line 1460, in 
> accepts
>   File "/home/mdipierro/make_web2py/web2py/gluon/dal.py", line 9244, in store
> RuntimeError: you must specify a Field(...,uploadfolder=...)
>
> Error snapshot [image: help] 
> <http://127.0.0.1:8000/admin/default/ticket/Movie_Alarm/127.0.0.1.2013-03-26.22-36-51.1dfde815-a9dd-4606-b2cd-529470cb5350#>
>  
>
> <type 'exceptions.RuntimeError'>(you must specify a 
> Field(...,uploadfolder=...))
>
> default.py lines around 306
>
>
> 301.
> 302.
> 303.
> 304.
> 305.
> 306.
>
> 307.
> 308.
> 309.
> 310.
>
>         print "len(request.args)",records
>     if len(request.args) and len(records):
>         form = SQLFORM(dbtable, records[0], deletable=True)
>     else:
>         form = SQLFORM.factory(dbtable,db.image_references)
>     if form.process().accepted:
>
>         print "form accepts"
>         response.flash = 'Entry for Images Database accepted,start creating 
> thumb'
>         makeThumbnail(dbtable,form.vars.id,(200,200))
>         print "thumbnail done"
>
>
>
>
>
>
> <type 'exceptions.RuntimeError'>(you must specify a 
> Field(...,uploadfolder=...)) I got no clue what whis line should tell me.
>
> the first time the default.py shows up with line 436 is very confusing 
> because the file has only 432 lines.
>
> Thanks for the help
>

-- 

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