yep. Scheduler's function are called OUTSIDE the web2py process, like in a 
shell, so there is a "fake" request that doesn't hold ALL the keys of a 
normal request.

Namely, request.env by default holds only

<Storage {'http_host': '127.0.0.1:8000', 'path_info': '/welcome/None/None', 
'web2py_runtime_gae': None, 'remote_addr': '127.0.0.1'}>


you can "inspect" available keys of the "fake" request in the shell 
itself....

web2py.py -M -S welcome
>>> request
<Storage {'function': 'index', 'is_local': False, 'wsgi': <Storage {}>, 
'is_restful': False, 'extension': 'html', 'vars': <Storage {}>, 
'global_settings': <Storage {'debugging': False, 'is_pypy': False, 
'gluon_parent': '/home/niphlod/Scrivania/web2py_source/web2py', 'is_jython': 
False, 'applications_parent': '/home/niphlod/Scrivania/web2py_source/web2py'
, 'cmd_options': <Values at 0x25fa488: {'verbose': False, 'ip': '127.0.0.1', 
'with_scheduler': False, 'ips': [], 'shutdown_timeout': 5, 'taskbar': False, 
'port': 8000, 'maxthreads': None, 'softcron': False, 'server_name': 
'li-mostro7', 'bpython': False, 'nogui': False, 'pid_filename': 
'httpserver.pid', 'extcron': False, 'runcron': False, 'run_system_tests': 
False, 'test': None, 'folder': 
'/home/niphlod/Scrivania/web2py_source/web2py', 'config': '', 'minthreads': 
None, 'winservice': '', 'shell': 'welcome', 'run': '', 'log_filename': 
'httpserver.log', 'debuglevel': 30, 'args': [''], 'socket_timeout': 5, 
'ssl_ca_certificate': None, 'scheduler': None, 'profiler_filename': None, 
'ssl_private_key': '', 'scheduler_groups': None, 'password': '<ask>', 
'request_queue_size': 5, 'ssl_certificate': '', 'cronjob': False, 
'numthreads': None, 'quiet': False, 'interfaces': None, 'import_models': 
True, 'timeout': 10, 'plain': False, 'nobanner': False}>, 'app_folders': set
([]), 'db_sessions': set([]), 'web2py_version': (2, 4, 1, 'alpha.2',datetime
.datetime(2013, 1, 14, 9, 43, 37)), 'cmd_args': []}>, 'args': [], 'cookies': 
<SimpleCookie: >, 'is_https': False, 'application': 'welcome', 'controller': 
'default', 'utcnow': datetime.datetime(2013, 1, 14, 20, 58, 31, 572057), 
'env': <Storage {'http_host': '127.0.0.1:8000', 'path_info': 
'/welcome/None/None', 'web2py_runtime_gae': None, 'remote_addr': '127.0.0.1'
}>, 'get_vars': <Storage {}>, 'folder': 'applications/welcome', 'now':datetime
.datetime(2013, 1, 14, 21, 58, 31, 572051), 'post_vars': <Storage {}>}>
>>> request.env
<Storage {'http_host': '127.0.0.1:8000', 'path_info': '/welcome/None/None', 
'web2py_runtime_gae': None, 'remote_addr': '127.0.0.1'}>




On Monday, January 14, 2013 6:12:42 PM UTC+1, mweissen wrote:
>
> I have found:
>
> In db.py I have something like 
> sn = request.env.server_name
> If this line is called by the scheduler sn gets the value None
>
>
> 2013/1/14 Niphlod <[email protected] <javascript:>>
>
>> ?
>>
>>
>> On Sunday, January 13, 2013 9:37:38 PM UTC+1, mweissen wrote:
>>
>>> Solved.
>>> I have tried to use request.env.server_name in db.py
>>>
>>> 2013/1/13 Martin Weissenboeck <[email protected]>
>>>
>>>> Now I have tried to reduce this problem:
>>>>
>>>> There is only one function in "myscheduler":
>>>>
>>>> myscheduler = Scheduler (db, dict(
>>>>     testmail=testmail,
>>>>     ))
>>>>
>>>> And testmail is:
>>>>
>>>> def testmail(text='mytext'):
>>>>     res = send_email(
>>>>                 to='[email protected]', 
>>>>                 subject="subject: %s" % text,
>>>>                 message="message: %s" % text,
>>>>                )
>>>>
>>>> But the error message remains:
>>>>
>>>>
>>>> Traceback (most recent call last):
>>>>   File "/home/www-data/web2py/gluon/**scheduler.py", line 214, in 
>>>> executor
>>>>     _env = env(a=a, c=c, import_models=True)
>>>>   File "/home/www-data/web2py/gluon/**shell.py", line 137, in env
>>>>     sys.exit(1)
>>>> SystemExit: 1
>>>>
>>>>
>>>>
>>>>
>>>> 2013/1/13 Martin Weissenboeck <[email protected]>
>>>>
>>>>> Repeats: 0=unlimitedRetry Failed: -1=unlimitedPeriod: secondsTimeout: 
>>>>> secondsSync Output: update output every n sec: 0=never Times Run: 
>>>>> Times Failed: 
>>>>> Tiemout:300 seconds. 
>>>>> The called functions needs about 2 seconds to complete.
>>>>>
>>>>>
>>>>> 2013/1/13 Niphlod <[email protected]>
>>>>>
>>>>> did you try to raise the timeout ?
>>>>>>
>>>>>>
>>>>>> On Sunday, January 13, 2013 2:43:12 PM UTC+1, mweissen wrote:
>>>>>>>
>>>>>>> The scheduler calls two diffent functions.
>>>>>>> In bothes the scheduler_run table contains:
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>>   File "/home/www-data/web2py/gluon/**s**cheduler.py", line 214, in 
>>>>>>> executor
>>>>>>>     _env = env(a=a, c=c, import_models=True)
>>>>>>>   File "/home/www-data/web2py/gluon/**s**hell.py", line 137, in env
>>>>>>>     sys.exit(1)
>>>>>>> SystemExit: 1
>>>>>>>
>>>>>>> Any hints?
>>>>>>> Reagards, Martin
>>>>>>>
>>>>>>
>>>>>>  -- 
>>  
>>   
>>
>

-- 



Reply via email to