[ http://issues.apache.org/jira/browse/MODPYTHON-106?page=all ] Graham Dumpleton closed MODPYTHON-106: --------------------------------------
> 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.7, 3.1.4 > Reporter: Graham Dumpleton > Fix For: 3.2.7 > Attachments: mod_python.c.diff.20060102-1 > > In mod_python 2.7.11, the code for handling the PythonAutoReload directive > was: > 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 > loaded 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 entry > was added to the config table object, instead, if there was an existing entry > 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_python.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 > object, it defaults to the auto reload feature being turned On. > Thus, if PythonAutoReload is set to "On" in the configuration files, the > Python code will find the value "1" and thus auto reload will be enabled. > Because 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 > additional argument whereby it can be specified that "0" should be set for > the value 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 > value, thus setting it to "0" will cause that code to think the option used > in that case (PythonInterpPerDirectory, PythonInterpPerDirective) is set to > on when it isn't, thus causing that to stop working correctly. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira