Thanks for the answer. 
I've found that one of my models does a conditional check on request 
object. 
However, when the function is called from the scheduler, there is no HTTP 
request, so there is no request object.

Is there a way to check if request object exists from inside the model?

I've tried this:
if 'request' in globals():
    #do stuff here

and this
try:
    request = request
except:
   request = None
if request:
    #do stuff here (I know, this is really bad thing to do)

Thanks in advance





El martes, 12 de enero de 2016, 16:59:26 (UTC-3), Niphlod escribió:
>
> it seems an error in the model definition, as line 166 in gluon.shell is 
> where an exception is raised when executing model files BEFORE calling the 
> controller.
> As I repeatedly said, scheduler is just calling shell at regular intervals 
> on steroids. If it works on the shell, it'll work on the scheduler too.
>
> so, 1st step. What if you execute the function in the shell directly ?
>
> web2py.py -M -S appname/controller_name/function_name
>
> The only thing that can sometimes get you in the corner is conditional 
> models ... If  you're using them, be sure when you are queuing the task, 
> that you do from the same controller which triggers the same conditional 
> models where the function is defined.
> Remember that the scheduler executes the same environment where the 
> queuing happened if you don't pass an explicit application_name parameter 
> (by default is current.request.application/current.request.controller) 
> which executes models/* and models/controller_name but not 
> models/other_controller_name
>
> On Tuesday, January 12, 2016 at 5:50:52 PM UTC+1, Lisandro wrote:
>>
>> I'm seeing this traceback error when I try to run a function defined in a 
>> model:
>>
>> Traceback (most recent call last): File 
>> "/var/www/medios/gluon/scheduler.py", line 295, in executor _env = env(a=
>> a, c=c, import_models=True) File "/var/www/medios/gluon/shell.py", line 
>> 166, in env sys.exit(1) SystemExit: 1
>>
>> However, if I call the function from within a controller/function, the 
>> function executes ok.
>> As I don't see an error pointing to my app's code, I thought I could ask 
>> here. What am I missing?
>>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to