please email it to me. the indentation is messed up.

Massimo

On Feb 19, 10:59 am, vamaq <[email protected]> wrote:
> Hi
> I'm still with the same problem. I tried everything I could think off,
> but I'm new with Web2Py and my tool case is quite empty.
> I will give the complete code so, if anybody have the time could
> reproduce the case could do it.
> Thanks,
>
> Juan
>
> #### Model ####
>
> db=SQLDB('sqlite://storage.db')
>
> db.define_table('recurso',
>     SQLField('nombre','string',length=100,notnull=True,unique=True))
> db.recurso.nombre.requires=[IS_NOT_IN_DB
> (db,'recurso.nombre'),IS_NOT_EMPTY()]
>
> db.define_table('objetivo',
>     SQLField
> ('descripcion','string',length=100,notnull=True,unique=True,
>         requires=[IS_NOT_IN_DB(db,'objetivo.descripcion'),IS_NOT_EMPTY
> ()]))
>
> db.define_table('rec_obj',
>     SQLField('recurso',db.recurso),
>     SQLField('objetivo',db.objetivo))
> db.rec_obj.recurso.requires=IS_IN_DB(db,'recurso.id','%(nombre)s')
> db.rec_obj.objetivo.requires=IS_IN_DB(db,'objetivo.id','%(descripcion)
> s')
>
> #### Controller ####
>
> def abm_recurso():
>
>     if request.vars.has_key('id'): records=db
> (db.recurso.id==request.vars.id).select()
>
>     if request.vars.has_key('id') and len(records):
>
>         form1=SQLFORM(db.recurso,records
> [0],deletable=True,submit_button='Modificar')
>         form3=SQLFORM(db.rec_obj,fields=
> ['objetivo'],submit_button='Agregar')
>
>         form3.vars.recurso=request.vars.id
>
>         records2 =db((db.recurso.id==db.rec_obj.recurso)&
> (db.objetivo.id==db.rec_obj.objetivo)&
> (db.recurso.id==request.vars.id)).select()
>
>     else:
>
>         form1=SQLFORM(db.recurso,submit_button='Agregar')
>         form3=FORM()
>         records2=''
>
>     form2=FORM(INPUT(_type='submit',_name='NuevoRecurso',_value='Nuevo
> Recurso'))
>
>     if form1.accepts(request.vars,session,formname='form_1') and
> request.vars.has_key('id'): redirect(URL(r=request,f='abm_recurso')) #
> Esto sería para limpiar el formulario
>     if form2.accepts(request.vars,session,formname='form_2'): redirect
> (URL(r=request,f='abm_recurso')) # Esto sería para limpiar el
> formulario
>     form3.accepts(request.vars,session,formname='form_3')
>
>     if form1.errors: response.flash='Form has Errors'
>     if form3.errors: response.flash='Form has Errors'
>
>     records=db().select(db.recurso.ALL)
>
>     return dict
> (form1=form1,form2=form2,form3=form3,records=records,records2=records2)
>
> ####  View ####
>
> {{extend 'layout.html'}}
> <h1>ABM Recursos</h1>
>     {{=form1}}
>     {{=form2}}
> <table>
>     {{if records2!=None: }}
>     {{for rec_obj in records2:}}
>         <tr>
>             <td>{{=rec_obj.objetivo.descripcion}}<td>
>         </tr>
>     {{pass}}
>     {{pass}}
> </table>
>     {{=form3}}
> <table>
>     {{for recurso in records:}}
>         <tr>
>             <td>{{=A(recurso.id,_href=URL(r=request,f='abm_recurso?id=
> %s'%recurso.id))}}<td>
>             <td>{{=recurso.nombre}}<td>
>         </tr>
>     {{pass}}
> </table>
>
> #### Steps to reproduce the error ####
>
> 1.- Insert a dummy record at db.objetivo
> 2.- Go to abm_recurso page
> 3.- Insert into the "Nombre" field any value and click on
> "Agregar" (at this point the new record should be displayed at the end
> of the page).
> 4.- Click on the ID of the recently added value. The page should
> change and give you the possibility to modify the record or to add a
> new relationship between db.recurso and db.objetivo. At this point you
> should have three buttons called "Modificar" "Nuevo Recurso" and
> "Agregar"
> 5.- Click on "Agregar" with the selected values at the form at the
> field "objetivo".
> Here you should have the error.
>
> On Feb 18, 6:34 pm, vamaq <[email protected]> wrote:
>
> > Hi everybody.
>
> > I' been analyzing the case and maybe the problem is related to the
> > line " form3=FORM() " at the controller. This line is inside a IF
> > statement and form3 is the one that triggers the error when it's
> > submitted.
>
> > When no ID is selected form3=FORM(), when an ID is selected
> > form3=SQLFORM (db.rec_obj,submit_button='Agregar',_formname='f3')
>
> > Is there any other way to define an emptyformso thisformis not
> > displayed when no ID is selected?
>
> > Thanks!
>
> > Juan
>
> > On Feb 17, 4:59 pm, Juan Andres Ramil <[email protected]>
> > wrote:
>
> > > Sorry, I forget to include the view (abm_recurso.html) for the controller.
> > > This view is important because it will give you the posibility to select a
> > > particular value to edit.
> > > The code of the view is:
>
> > > {{extend 'layout.html'}}
> > > <h1>ABM Recursos</h1>
> > >     {{=form1}}
> > >     {{=form2}}
> > > <table>
> > >     {{if records2!=None: }}
> > >     {{for rec_obj in records2:}}
> > >         <tr>
> > >             <td>{{=rec_obj.objetivo.descripcion}}<td>
> > >         </tr>
> > >     {{pass}}
> > >     {{pass}}
> > > </table>
> > >     {{=form3}}
> > > <table>
> > >     {{for recurso in records:}}
> > >         <tr>
> > >             <td>{{=A(recurso.id,_href=URL(r=request,f='abm_recurso?id=%s'%
> > > recurso.id))}}<td>
> > >             <td>{{=recurso.nombre}}<td>
> > >         </tr>
> > >     {{pass}}
> > > </table>
>
> > > The steps needed to reproduce the error are the following:
>
> > > 1.- Insert a dummy record at db.objetivo
> > > 2.- Go to abm_recurso page
> > > 3.- Insert into the "Nombre" field any value and click on "Agregar" (at 
> > > this
> > > point the new record should be displayed at the end of the page).
> > > 4.- Click on the ID of the recently added value. The page should change 
> > > and
> > > give you the possibility to modify record or to add a new relationship
> > > between "recurso" and "objetivo"
> > > At this point you should have three buttons called "Modificar" "Nuevo
> > > Recurso" and "Agregar"
> > > 5.- Click on "Agregar" with the selected values at theformat the fields
> > > "recurso" and "objetivo".
>
> > > At this point, the error should happend.
> > > Let me know if you need any other detail. Thanks!
>
> > > Juan
>
> > > 2009/2/17 mdipierro <[email protected]>
>
> > > > I cannot reproduce the problem. Can you send me an applicance
> > > > containing some data and a step by step example to reproduce it?
>
> > > > Massimo
>
> > > > On Feb 17, 7:09 am, vamaq <[email protected]> wrote:
> > > > > Continuing with the exercise; I've added some additional complexity to
> > > > > the controller. The problem is that I'm getting the "user is tampering
> > > > > withform" error again.
>
> > > > > Details:
>
> > > > > - I'm working with the update revision 729 at SVN (Python 2.5.4)
> > > > > - The model continues to be the same.
> > > > > - The error is raised when I submit either form3 or form2.
> > > > > - form1: handles all the actions on "recurso"
> > > > > - form2: Is only a button to clean and start again. (Submitting this
> > > > >formrise an error)
> > > > > - form3: at the moment only gives the possibility to chose one
> > > > > "recurso" and one "objetivo" and create a relationship. (Submitting
> > > > > thisformrise an error)
>
> > > > > Objective:
>
> > > > > - The final idea is to create a simple page that allows to add /
> > > > > modify / delete "recursos" and also gives to the user the possibility
> > > > > to specify relationships with many "objetivos".
> > > > > - The controller is not yet completed. But in theory it should work
> > > > > (obviously is not)
>
> > > > > Following is the new controller and finally is the error stack.
> > > > > Thanks for your help!
>
> > > > > Juan
>
> > > > > ################################ Controller
> > > > > ########################################
>
> > > > > def abm_recurso():
>
> > > > >     if request.vars.has_key('id'): records=db
> > > > > (db.recurso.id==request.vars.id).select()
>
> > > > >     if request.vars.has_key('id') and len(records):
>
> > > > >         form1=SQLFORM(db.recurso,records
> > > > > [0],deletable=True,submit_button='Modificar')
>
> > > > >         rec_obj=db((db.recurso.id==db.rec_obj.recurso)&
> > > > > (db.objetivo.id==db.rec_obj.objetivo)&
> > > > > (db.recurso.id==request.vars.id))
> > > > >         records2=rec_obj.select()
>
> > > > >         form3=SQLFORM
> > > > > (db.rec_obj,submit_button='Agregar',_formname='f3')
>
> > > > >     else:
>
> > > > >         form1=SQLFORM(db.recurso,submit_button='Agregar')
> > > > >         form3=FORM()
> > > > >         records2=''
>
> > > > >     form2=FORM(INPUT(_type='submit',_name='NuevoRecurso',_value='Nuevo
> > > > > Recurso'))
>
> > > > >     if form1.accepts(request.vars,session,formname='form1') and
> > > > > request.vars.has_key('id'): redirect(URL(r=request,f='abm_recurso')) #
> > > > > to clean theform.
> > > > >     if form2.accepts(request.vars,session,formname='form2'): redirect
> > > > > (URL(r=request,f='abm_recurso')) # to clean theform.
> > > > >     form3.accepts(request.vars,session,formname='form3')
>
> > > > >     if form1.errors: response.flash='Formhas Errors'
> > > > >     if form3.errors: response.flash='Formhas Errors'
>
> > > > >     records=db().select(db.recurso.ALL)
>
> > > > >     return dict
> > > > > (form1=form1,form2=form2,form3=form3,records=records,records2=records2)
>
> > > > > ################################ Error
> > > > > ########################################
>
> > > > > Traceback (most recent call last):
> > > > >   File "f:\Web2Py\web2py.dev\gluon\restricted.py", line 98, in
> > > > > restricted
> > > > >     exec ccode in environment
> > > > >   File "f:/Web2Py/web2py.dev/applications/Recursos/controllers/
> > > > > default.py", line 70, in <module>
> > > > >   File "f:\Web2Py\web2py.dev\gluon\globals.py", line 75, in <lambda>
> > > > >     self._caller = lambda f: f()
> > > > >   File "f:/Web2Py/web2py.dev/applications/Recursos/controllers/
> > > > > default.py", line 30, in abm_recurso
> > > > >     form3.accepts(request.vars,session,formname='form3')
> > > > >   File "f:\Web2Py\web2py.dev\gluon\sqlhtml.py", line 482, in accepts
> > > > >     raise SyntaxError, 'user is tampering withform'
> > > > > SyntaxError: user is tampering withform
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to