worked flawlessly :) .. thank you On Dec 30, 11:21 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > My bad. Try this: > > @auth.requires(not request.wsgi or auth.has_permission('least')) > > On Dec 30, 12:13 pm, vvk <varunk.ap...@gmail.com> wrote: > > > Sir, > > Cron isnt working when I put that validator, error given is same as > > mentioned earlier . Cron is working properly without any validator. > > > Here is my function. Kindly let me know if any problem is there. > > > @auth.requires(not request.env.remote_addr or auth.has_permission > > ('least')) > > def takebackup(): > > """ > > Max. No. of backups are four. When fourth one is saved, check is done > > if there are already four, if there are four, oldest backup is deleted > > """ > > import os > > file_to_delete = "" > > backup_count = db(db.backup_entry.id > 0).count() > > > if backup_count > 3: > > least_entry = db.backup_entry.dateofentry.min() > > query = db(db.backup_entry.id > 0).select() > > least_entry = datetime.datetime.today() > > for i in query: > > if i.dateofentry < least_entry: > > least_entry = i.dateofentry > > > db(db.backup_entry.dateofentry == least_entry).delete > > () > > file_to_delete = "backup" + "_" + str(least_entry) + > > ".csv" > > try: > > os.remove ('/home/www-data/backups/lsi/' + > > file_to_delete) > > except: > > do_nothing = 1 > > > current_time = str(datetime.datetime.today()).split(".") > > [0] # File name > > file_backup = "backup" + "_" + current_time + ".csv" > > > db.export_to_csv_file(open('/home/www-data/backups/lsi/' + > > file_backup,'wb')) > > db.backup_entry.insert(dateofentry = current_time) > > db.commit() > > return dict(form='') > > > On Dec 30, 11:36 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > 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.