Resolved: (MODPYTHON-106) PythonAutoReload directive can't
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 > Resolved: (MODPYTHON-106) PythonAutoReload directive can't




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

    Resolved: (MODPYTHON-106) PythonAutoReload directive can't  
Jim Gallacher (JIRA)


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


 
01-14-06 02:18 AM

[ http://issues.apache.org/jira/brows...ON-106?page=all ]

Jim Gallacher resolved MODPYTHON-106:
-------------------------------------

Fix Version: 3.2
Resolution: Fixed

> 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.4, 3.1.3, 3.2
>     Reporter: Graham Dumpleton
>      Fix For: 3.2
>  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 lo
aded 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) 
3;
>     const char *rc = python_directive_flag(mconfig, "PythonAutoReload", va
l);
>     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 rem
oved. The removal would come into play when the option was set to "On" at global sco
pe
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 th
e 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("PythonAutoRe
load", 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 co
de will find the value "1" and thus auto reload will be enabled. Because of the C co
de changes above though, when PythonAutoReload is set to "Off" in the config, no ent
ry
is put in the config table object at all and because the Python code can't find it, it defau
lts 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 Apac
he configuration directive.
> One solution is to change python_directive_flag() function to take an addi
tional argument whereby it can be specified that "0" should be set for the v
alue 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 ca
se.
> One can't just always set it to "0", as other code in mod_python.c uses the fact t
hat an option exists to mean it is set. Ie., it doesn't check the value, thus settin
g it to "0" will cause that code to think the option used in that case (PythonInterp
Per
Directory, PythonInterpPerDirective) is set to on when it isn't, thus causin
g that to stop working correctly.






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:43 AM.      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