Hi all,
I'm trying to setup a form to manage two tables:
db.define_table('pratiche',
Field('nome', requires=IS_NOT_EMPTY()),
Field('descrizione', 'text', requires=IS_NOT_EMPTY()),
Field('stato_pratica', requires=IS_IN_SET(['aperta',
'attesa', 'chiusa'])),
auth.signature)
db.define_table('allegati',
Field('tipo_allegato', requires=IS_IN_SET(['mandato',
'comparsa preliminare', 'relazione ctu', 'parcella'])),
Field('doc_filename'),
Field('doc', 'upload'),
Field('pratica', 'reference pratiche', writable = False,
readable = False))
Table allegati contain uploaded file referred to record in pratiche.
My controller form create a new record is:
@auth.requires_login()
def create():
form = SQLFORM.factory(db.pratiche, db.allegati)
form.vars.stato_pratica = 'aperta'
form.vars.tipo_allegato = 'mandato'
form.add_button('Back', URL('index'))
if form.process(onvalidation=create_form_process).accepted:
"""TODO
trovare il modo di non far inserire un nome di file
ma di salvare almeno la categoria a cui si associa
presa dal menu a tendina del tipo di file
"""
id = db.pratiche.insert(**db.pratiche._filter_fields(form.vars))
form.vars.pratiche=id
id = db.allegati.insert(**db.allegati._filter_fields(form.vars))
form.vars.allegati=id
session.flash = T('Posted')
redirect(URL('index'))
elif form.errors:
session.flash = T('Il form ha degli errori')
return locals()
def create_form_process(form):
form.vars.doc_filename = form.vars.tipo_allegato
And my views is
{{extend 'layout.html'}}
<h2>Nuova pratica</h2>
{{=form}}
The form is show well but when I try su submit I receive this error that I
don't understand
Error ticket for "studiolegale"Ticket ID
127.0.0.1.2016-04-28.23-56-24.d61a1296-63cc-4f78-9a35-ec021d430d86
<type 'exceptions.RuntimeError'> you must specify a Field(...,
uploadfolder=...)Versione
web2py™ Version 2.14.5-stable+timestamp.2016.04.14.03.26.16
Python Python 2.7.3:
/Users/andrea/Desktop/web2py/web2py.app/Contents/MacOS/python (prefix:
/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources)Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Traceback (most recent call last):
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/gluon/restricted.py",
line 227, in restricted
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/applications/studiolegale/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/studiolegale/controllers/default.py>,
line 95, in <module>
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/gluon/globals.py",
line 417, in <lambda>
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/gluon/tools.py",
line 4258, in f
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/applications/studiolegale/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/studiolegale/controllers/default.py>,
line 13, in create
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/gluon/html.py",
line 2300, in process
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/gluon/html.py",
line 2238, in validate
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/gluon/sqlhtml.py",
line 1662, in accepts
File
"/Users/andrea/Desktop/web2py/web2py.app/Contents/Resources/gluon/packages/dal/pydal/objects.py",
line 1519, in store
RuntimeError: you must specify a Field(..., uploadfolder=...)
What are my errors?
I perform the right way to do this?
Thanks a lot
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.