You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by "Graham Dumpleton (JIRA)" <ji...@apache.org> on 2005/01/19 11:52:17 UTC

[jira] Created: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Not possible to have empty value when using PythonOption.
---------------------------------------------------------

         Key: MODPYTHON-6
         URL: http://issues.apache.org/jira/browse/MODPYTHON-6
     Project: mod_python
        Type: Wish
    Versions: 3.1.3    
    Reporter: Graham Dumpleton
    Priority: Minor


When I try and set the variable to an empty string. Ie.,

   PythonOption Name ""

I get an Apache error:

> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was 
> unable to complete your request.
>
> Please contact the server administrator,  you at example.com and inform 
> them of the time the error occurred, and anything you might have done 
> that may have caused the error.
>
> More information about this error may be available in the server error 
> log.
> Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost 
> Port 8080

There is also no explicit way to unset a key/value which is inherited from a directory
higher up in the hierarchy. Not being able to unset a key/value pair or set the
value to empty, means that to disable an inherited value you have to set it to
some magic value which is taken as meaning that it has no affect. Ie., the
application has to do special interpretation of the value.

-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-6?page=history ]
     
Nicolas Lehuen resolved MODPYTHON-6:
------------------------------------

    Resolution: Fixed

This should be fixed now (subversion revision 125786). I've used "" as the marker for an entry to remove, since it cannot collide with a real value (until now, "" was a forbidden value, and now, "" in indistinguishable from no value at all due to the TAKE_12 directives behaviour). I've updated the test cases and the documentation.

I realize that this solve the "unsetting" problem, but it is still not possible to have an empty value when using PythonOption. Is this really a problem ? If so when can solve it once  and for all by defining PythonOption as a RAW_ARGS directive, and parsing ourselves the directive arguments. But it's not something I'm very keen on doing in C.

> Not possible to have empty value when using PythonOption.
> ---------------------------------------------------------
>
>          Key: MODPYTHON-6
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-6
>      Project: mod_python
>         Type: Wish
>     Versions: 3.1.3
>     Reporter: Graham Dumpleton
>     Assignee: Nicolas Lehuen
>     Priority: Minor
>      Fix For: 3.1.4

>
> When I try and set the variable to an empty string. Ie.,
>    PythonOption Name ""
> I get an Apache error:
> > Internal Server Error
> >
> > The server encountered an internal error or misconfiguration and was 
> > unable to complete your request.
> >
> > Please contact the server administrator,  you at example.com and inform 
> > them of the time the error occurred, and anything you might have done 
> > that may have caused the error.
> >
> > More information about this error may be available in the server error 
> > log.
> > Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost 
> > Port 8080
> There is also no explicit way to unset a key/value which is inherited from a directory
> higher up in the hierarchy. Not being able to unset a key/value pair or set the
> value to empty, means that to disable an inherited value you have to set it to
> some magic value which is taken as meaning that it has no affect. Ie., the
> application has to do special interpretation of the value.

-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-6?page=comments#action_57836 ]
     
Nicolas Lehuen commented on MODPYTHON-6:
----------------------------------------

At least we no longer get an internal server error, though having Apache silently ignore this is no better...

> Not possible to have empty value when using PythonOption.
> ---------------------------------------------------------
>
>          Key: MODPYTHON-6
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-6
>      Project: mod_python
>         Type: Wish
>     Versions: 3.1.3
>     Reporter: Graham Dumpleton
>     Priority: Minor

>
> When I try and set the variable to an empty string. Ie.,
>    PythonOption Name ""
> I get an Apache error:
> > Internal Server Error
> >
> > The server encountered an internal error or misconfiguration and was 
> > unable to complete your request.
> >
> > Please contact the server administrator,  you at example.com and inform 
> > them of the time the error occurred, and anything you might have done 
> > that may have caused the error.
> >
> > More information about this error may be available in the server error 
> > log.
> > Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost 
> > Port 8080
> There is also no explicit way to unset a key/value which is inherited from a directory
> higher up in the hierarchy. Not being able to unset a key/value pair or set the
> value to empty, means that to disable an inherited value you have to set it to
> some magic value which is taken as meaning that it has no affect. Ie., the
> application has to do special interpretation of the value.

-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-6?page=history ]

Nicolas Lehuen updated MODPYTHON-6:
-----------------------------------

      Assign To: Nicolas Lehuen
    Fix Version: 3.1.4

> Not possible to have empty value when using PythonOption.
> ---------------------------------------------------------
>
>          Key: MODPYTHON-6
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-6
>      Project: mod_python
>         Type: Wish
>     Versions: 3.1.3
>     Reporter: Graham Dumpleton
>     Assignee: Nicolas Lehuen
>     Priority: Minor
>      Fix For: 3.1.4

>
> When I try and set the variable to an empty string. Ie.,
>    PythonOption Name ""
> I get an Apache error:
> > Internal Server Error
> >
> > The server encountered an internal error or misconfiguration and was 
> > unable to complete your request.
> >
> > Please contact the server administrator,  you at example.com and inform 
> > them of the time the error occurred, and anything you might have done 
> > that may have caused the error.
> >
> > More information about this error may be available in the server error 
> > log.
> > Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost 
> > Port 8080
> There is also no explicit way to unset a key/value which is inherited from a directory
> higher up in the hierarchy. Not being able to unset a key/value pair or set the
> value to empty, means that to disable an inherited value you have to set it to
> some magic value which is taken as meaning that it has no affect. Ie., the
> application has to do special interpretation of the value.

-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Re: [jira] Commented: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Posted by "Gregory (Grisha) Trubetskoy" <gr...@apache.org>.
AFAICT this should work. We also need a note in the docs to note that "" 
unsets the string. And a test case for that would be total perfection 
nirvana :-)

On Wed, 19 Jan 2005, Nicolas Lehuen (JIRA) wrote:

>     [ http://issues.apache.org/jira/browse/MODPYTHON-6?page=comments#action_57789 ]
>
> Nicolas Lehuen commented on MODPYTHON-6:
> ----------------------------------------
>
> I'm not an expert in APR tables, but what about this patch ? If the 
> value has length 0, we unset it from the table. The trouble is that I 
> don't know if the inheritance mechanism is compatible with this.
>
> Index: mod_python.c
> ===================================================================
> --- mod_python.c	(revision 125635)
> +++ mod_python.c	(working copy)
> @@ -1533,16 +1533,26 @@
> static const char *directive_PythonOption(cmd_parms *cmd, void * mconfig,
>                                           const char *key, const char *val)
> {
> -
>     py_config *conf;
>
> -    conf = (py_config *) mconfig;
> -    apr_table_set(conf->options, key, val);
>
> -    conf = ap_get_module_config(cmd->server->module_config,
> -                                &python_module);
> -    apr_table_set(conf->options, key, val);
> +    if(strlen(val)>0) {
> +        conf = (py_config *) mconfig;
> +        apr_table_set(conf->options, key, val);
>
> +        conf = ap_get_module_config(cmd->server->module_config,
> +                                    &python_module);
> +        apr_table_set(conf->options, key, val);
> +    }
> +    else {
> +        conf = (py_config *) mconfig;
> +        apr_table_unset(conf->options, key);
> +
> +        conf = ap_get_module_config(cmd->server->module_config,
> +                                    &python_module);
> +        apr_table_unset(conf->options, key);
> +    }
> +
>     return NULL;
> }
>
>
>
>> Not possible to have empty value when using PythonOption.
>> ---------------------------------------------------------
>>
>>          Key: MODPYTHON-6
>>          URL: http://issues.apache.org/jira/browse/MODPYTHON-6
>>      Project: mod_python
>>         Type: Wish
>>     Versions: 3.1.3
>>     Reporter: Graham Dumpleton
>>     Priority: Minor
>
>>
>> When I try and set the variable to an empty string. Ie.,
>>    PythonOption Name ""
>> I get an Apache error:
>>> Internal Server Error
>>>
>>> The server encountered an internal error or misconfiguration and was
>>> unable to complete your request.
>>>
>>> Please contact the server administrator,  you at example.com and inform
>>> them of the time the error occurred, and anything you might have done
>>> that may have caused the error.
>>>
>>> More information about this error may be available in the server error
>>> log.
>>> Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost
>>> Port 8080
>> There is also no explicit way to unset a key/value which is inherited from a directory
>> higher up in the hierarchy. Not being able to unset a key/value pair or set the
>> value to empty, means that to disable an inherited value you have to set it to
>> some magic value which is taken as meaning that it has no affect. Ie., the
>> application has to do special interpretation of the value.
>
> --
> 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
> -
> If you want more information on JIRA, or have a bug to report see:
>   http://www.atlassian.com/software/jira
>

[jira] Commented: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-6?page=comments#action_57789 ]
     
Nicolas Lehuen commented on MODPYTHON-6:
----------------------------------------

I'm not an expert in APR tables, but what about this patch ? If the value has length 0, we unset it from the table. The trouble is that I don't know if the inheritance mechanism is compatible with this.

Index: mod_python.c
===================================================================
--- mod_python.c	(revision 125635)
+++ mod_python.c	(working copy)
@@ -1533,16 +1533,26 @@
 static const char *directive_PythonOption(cmd_parms *cmd, void * mconfig, 
                                           const char *key, const char *val)
 {
-
     py_config *conf;
 
-    conf = (py_config *) mconfig;
-    apr_table_set(conf->options, key, val);
 
-    conf = ap_get_module_config(cmd->server->module_config,
-                                &python_module);
-    apr_table_set(conf->options, key, val);
+    if(strlen(val)>0) {
+        conf = (py_config *) mconfig;
+        apr_table_set(conf->options, key, val);
 
+        conf = ap_get_module_config(cmd->server->module_config,
+                                    &python_module);
+        apr_table_set(conf->options, key, val);
+    }
+    else {
+        conf = (py_config *) mconfig;
+        apr_table_unset(conf->options, key);
+
+        conf = ap_get_module_config(cmd->server->module_config,
+                                    &python_module);
+        apr_table_unset(conf->options, key);
+    }
+
     return NULL;
 }
 


> Not possible to have empty value when using PythonOption.
> ---------------------------------------------------------
>
>          Key: MODPYTHON-6
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-6
>      Project: mod_python
>         Type: Wish
>     Versions: 3.1.3
>     Reporter: Graham Dumpleton
>     Priority: Minor

>
> When I try and set the variable to an empty string. Ie.,
>    PythonOption Name ""
> I get an Apache error:
> > Internal Server Error
> >
> > The server encountered an internal error or misconfiguration and was 
> > unable to complete your request.
> >
> > Please contact the server administrator,  you at example.com and inform 
> > them of the time the error occurred, and anything you might have done 
> > that may have caused the error.
> >
> > More information about this error may be available in the server error 
> > log.
> > Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost 
> > Port 8080
> There is also no explicit way to unset a key/value which is inherited from a directory
> higher up in the hierarchy. Not being able to unset a key/value pair or set the
> value to empty, means that to disable an inherited value you have to set it to
> some magic value which is taken as meaning that it has no affect. Ie., the
> application has to do special interpretation of the value.

-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-6?page=comments#action_57835 ]
     
Nicolas Lehuen commented on MODPYTHON-6:
----------------------------------------

Alas it doesn't work...

First I add to change the PythonOption directive from the TAKE_2 type into the TAKE_12 type. This way the Apache server allows us to write :

PythonOption test ""

Otherwise we get a nice error message, this is not valid for a TAKE_2 directive.

I've written the code that checks whether the second value is provided (the configuration engine gives us a NULL value when it is not) and did as planned, with unset() calls. The problem is that is does remove the entry from the local table, but not from the parent table from which the configuration inherits. The result is that the option is not removed. Unfortunately, it seems that the only way to proceed is to choose a special value for the option, set it in the local table, and have the code for req.get_options() try to filter out those special values.

At that point I wonder whether this issue is worth the trouble, but I'll keep on going on the problem. 

PS. congratulations for the unit testing framework, that's quite a feat. I've already checked in three new tests for the PythonOption directive. I've done it by copy/pasting the code, I hope I've got it correctly. BTW, the testing is quite Unix-oriented, I had to make some modification (not checked in) for the tests to run under Win32.



> Not possible to have empty value when using PythonOption.
> ---------------------------------------------------------
>
>          Key: MODPYTHON-6
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-6
>      Project: mod_python
>         Type: Wish
>     Versions: 3.1.3
>     Reporter: Graham Dumpleton
>     Priority: Minor

>
> When I try and set the variable to an empty string. Ie.,
>    PythonOption Name ""
> I get an Apache error:
> > Internal Server Error
> >
> > The server encountered an internal error or misconfiguration and was 
> > unable to complete your request.
> >
> > Please contact the server administrator,  you at example.com and inform 
> > them of the time the error occurred, and anything you might have done 
> > that may have caused the error.
> >
> > More information about this error may be available in the server error 
> > log.
> > Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost 
> > Port 8080
> There is also no explicit way to unset a key/value which is inherited from a directory
> higher up in the hierarchy. Not being able to unset a key/value pair or set the
> value to empty, means that to disable an inherited value you have to set it to
> some magic value which is taken as meaning that it has no affect. Ie., the
> application has to do special interpretation of the value.

-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Closed: (MODPYTHON-6) Not possible to have empty value when using PythonOption.

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-6?page=all ]
     
Graham Dumpleton closed MODPYTHON-6:
------------------------------------


> Not possible to have empty value when using PythonOption.
> ---------------------------------------------------------
>
>          Key: MODPYTHON-6
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-6
>      Project: mod_python
>         Type: Wish
>     Versions: 3.1.3
>     Reporter: Graham Dumpleton
>     Assignee: Nicolas Lehuen
>     Priority: Minor
>      Fix For: 3.2.7

>
> When I try and set the variable to an empty string. Ie.,
>    PythonOption Name ""
> I get an Apache error:
> > Internal Server Error
> >
> > The server encountered an internal error or misconfiguration and was 
> > unable to complete your request.
> >
> > Please contact the server administrator,  you at example.com and inform 
> > them of the time the error occurred, and anything you might have done 
> > that may have caused the error.
> >
> > More information about this error may be available in the server error 
> > log.
> > Apache/2.0.51 (Unix) mod_python/3.1.3 Python/2.3 Server at localhost 
> > Port 8080
> There is also no explicit way to unset a key/value which is inherited from a directory
> higher up in the hierarchy. Not being able to unset a key/value pair or set the
> value to empty, means that to disable an inherited value you have to set it to
> some magic value which is taken as meaning that it has no affect. Ie., the
> application has to do special interpretation of the value.

-- 
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