Created: (MODPYTHON-106) PythonAutoReload directive can't be turned off in config.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache Mod-Python > Created: (MODPYTHON-106) PythonAutoReload directive can't be turned off in config.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Created: (MODPYTHON-106) PythonAutoReload directive can't be turned off in config.  
Graham Dumpleton (JIRA)


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-02-06 07:47 AM

PythonAutoReload directive can't be turned off in config.
---------------------------------------------------------

Key: MODPYTHON-106
URL: http://issues.apache.org/jira/browse/MODPYTHON-106
Project: mod_python
Type: Bug
Components: core
Versions: 3.1.3, 3.2, 3.1.4
Reporter: Graham Dumpleton


In mod_python 2.7.11, the code for handling the PythonAutoReload directive w
as:

static const char *directive_PythonAutoReload(cmd_parms *cmd,
void *mconfig, int val) {
if (val)
return python_directive(cmd, mconfig, "PythonAutoReload", "1");
else
return python_directive(cmd, mconfig, "PythonAutoReload", "0");
}

Thus, if PythonAutoReload was set to "Off", the config table object was load
ed with PythonAutoReload set to "0".

In mod_python 3.X at some point, it was changed to:

static const char *python_directive_flag(void * mconfig,
char *key, int val)
{
py_config *conf;

conf = (py_config *) mconfig;

if (val) {
apr_table_set(conf->directives, key, "1");
}
else {
apr_table_unset(conf->directives, key);
}

return NULL;
}

static const char *directive_PythonAutoReload(cmd_parms *cmd,
void *mconfig, int val) {
const char *rc = python_directive_flag(mconfig, "PythonAutoReload", val);

if (!rc) {
py_config *conf = ap_get_module_config(cmd->server->module_config,
&python_module);
return python_directive_flag(conf, "PythonAutoReload", val);
}
return rc;
}

Since that change, when PythonAutoReload was set ot "Off", no "0" value entr
y was added to the config table object, instead, if there was an existing en
try it was removed. The removal would come into play when the option was set
 to "On" at global scope in
main Apache configuration and then set to "Off" in a .htaccess file or other
 lesser scope such as a Directory directive.

The end result was that there was only an entry for PythonAutoReload in the 
config table object when it was set. When it existed, its value was "1".

The problem now is that the code which checks for PythonAutoReload in mod_py
thon.apache module uses:

module = import_module(module_name,
autoreload=int(config.get("PythonAutoReload", 1)),
log=debug)

That is, if the PythonAutoReload option doesn't exist in the config table ob
ject, it defaults to the auto reload feature being turned On.

Thus, if PythonAutoReload is set to "On" in the configuration files, the Pyt
hon code will find the value "1" and thus auto reload will be enabled. Becau
se of the C code changes above though, when PythonAutoReload is set to "Off"
 in the config, no entry is
put in the config table object at all and because the Python code can't find
 it, it defaults to using "1" with the result that auto reload will again be
 on.

In other words, it isn't possible to turn the feature off through the Apache
 configuration directive.

One solution is to change python_directive_flag() function to take an additi
onal argument whereby it can be specified that "0" should be set for the val
ue instead of the value being removed. Thus:

static const char *python_directive_flag(void * mconfig,
char *key, int val, int set)
{
py_config *conf;

conf = (py_config *) mconfig;

if (val) {
apr_table_set(conf->directives, key, "1");
}
else {
if (set) {
apr_table_set(conf->directives, key, "0");
}
else {
apr_table_unset(conf->directives, key);
}
}

return NULL;
}

All calls to this function except for PythonAutoReload case should supply "0
" for additional argument, with "1" being supplied for PythonAutoReload case
.

One can't just always set it to "0", as other code in mod_python.c uses the 
fact that an option exists to mean it is set. Ie., it doesn't check the valu
e, thus setting it to "0" will cause that code to think the option used in t
hat case (PythonInterpPerDi
rectory, PythonInterpPerDirective) is set to on when it isn't, thus causing 
that to stop working correctly.







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:35 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register