if not request.args:
return redirect()

On 23 Maj, 08:43, annet.verm...@gmail.com wrote:
> Massimo,
>
> After restarting the server if not record: worked.
>
> However, further down the workflow there is an error ticket issued
> when the user clicks the submit button.
>
> My custom update function:
>
> @auth.requires_membership('core_manager')
> def update_address():
>     response.view='core/update.html'
>     response.navigationfunction= T('Update/delete address')
>     db.adres.bedrijf.writable=False
>     record_id=request.args[0]
>     record=db(db.adres.id==record_id).select(db.adres.bedrijf)[0]
>     form=[]
>     if not record:
>         redirect(URL(r=request,f='crud_address'))
>     elif not record.bedrijf==auth.user.bedrijf:
>         redirect(URL(r=request,f='crud_address'))
>     form=crud.update(db.adres,request.args[0])
>     return dict(form=form)
>
> The error traceback:
> Traceback (most recent call last):
>   File "/Library/Python/2.5/site-packages/web2pyfitwise/gluon/
> restricted.py", line 98, in restricted
>     exec ccode in environment
>   File "/Library/Python/2.5/site-packages/web2pyfitwise/applications/
> cms/controllers/core.py", line 68, in <module>
>   File "/Library/Python/2.5/site-packages/web2pyfitwise/gluon/
> globals.py", line 75, in <lambda>
>     self._caller = lambda f: f()
>   File "/Library/Python/2.5/site-packages/web2pyfitwise/gluon/
> tools.py", line 1045, in f
>     return action(*a, **b)
>   File "/Library/Python/2.5/site-packages/web2pyfitwise/applications/
> cms/controllers/core.py", line 31, in update_address
>     record_id=request.args[0]
> IndexError: list index out of range
>
> I guess I need something like:
>
>  next=URL(r=request,f='core/crud_address')
>
> In the update_address() function to return to the previous function.
>
> @auth.requires_membership('core_manager')
> def crud_address():
>     response.functionname= T('CRUD adres')
>     db.adres.bedrijf.writable=False
>     db.adres.bedrijf.default=auth.user.bedrijf
>     form=crud.create(db.adres)
>     records=db(db.adres.bedrijf==auth.user.bedrijf)\
>     .select(db.adres.ALL,orderby=db.adres.adressoort)
>     if form.accepts(form.vars,session):
>        response.flash=T('new record created')
>     elif form.errors:
>         response.flash=T('form has errors')
>     else:
>         response.flash=T('please fill the form')
>     return dict(form=form,records=records)
>
> I look forward to your reply.
>
> Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to