You are referring to the auth decorator. Try this:

@auth.requires(not request.env.remote_addr or auth.has_permission
('xyz'))
def takebackup():

When the request comes from cron there is no request.env.remote_addr



On Dec 29, 9:29 pm, vvk <varunk.ap...@gmail.com> wrote:
> Hi sir,
> Cron job function in my application is working only when there is no
> validator for that function.
>
> My function:
> @auth.requires_permision('xyz')
> def takebackup():
>
> Is there a way to put a validator for that function because if there
> is no validator, any one can run backup function.
>
> This is the error I'm getting when there is a validator like
> @auth.requires_permission('xyz')
>
> Traceback (most recent call last):
>   File "web2py.py", line 20, in <module>
>     gluon.widget.start(cron=True)
>   File "/home/www-data/web2py/gluon/widget.py", line 743, in start
>     import_models=options.import_models, startfile=options.run)
>   File "/home/www-data/web2py/gluon/shell.py", line 163, in run
>     exec ('print %s()' % f, _env)
>   File "<string>", line 1, in <module>
>   File "/home/www-data/web2py/gluon/tools.py", line 1688, in f
>     redirect(self.settings.login_url + '?_next='+urllib.quote(next))
>   File "/home/www-data/web2py/gluon/http.py", line 104, in redirect
>     Location=location)
> gluon.http.HTTP
>
> On Dec 29, 11:05 pm, vvk <varunk.ap...@gmail.com> wrote:
>
> > Thanks sir, it's working now.
>
> > On Dec 29, 10:57 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > 0-59/1 * * * * user *default/index
>
> > > On Dec 29, 11:55 am, vvk <varunk.ap...@gmail.com> wrote:
>
> > > > Hi,
> > > > I'm getting an error for putting cron in default welcome application
> > > > which came with web2py 1.74.4 src code
>
> > > > I edited crontab file in welcome application as:
> > > > 0-59/1 * * * * *default/index
>
> > > > Error:
>
> > > > WARNING:root:WEB2PY CRON: exception: list index out of range
> > > > WARNING:root:Traceback (most recent call last):
> > > >   File "/Users/varun/Downloads/web2py/gluon/contrib/cron.py", line
> > > > 293, in crondance
> > > >     task = parsecronline(cline)
> > > >   File "/Users/varun/Downloads/web2py/gluon/contrib/cron.py", line
> > > > 230, in parsecronline
> > > >     task['cmd'] = params[6].strip()
> > > > IndexError: list index out of range
>
> > > > WARNING:root:WEB2PY CRON: exception: list index out of range
>
> > > > Any help would be greatly appreciated.
>
>

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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