Roundup Tracker - Issues

Issue 2550821

classification
mod_python 3.4.1 - add_cgi_vars() instead of add_common_vars()
Type: crash Severity: major
Components: Versions: 1.5
process
Status: closed accepted
:
: rouilj : ber, grisha, jerrykan, rouilj
Priority: : patch

Created on 2013-11-07 20:27 by grisha, last changed 2019-10-02 21:26 by rouilj.

Messages
msg4943 Author: [hidden] (grisha) Date: 2013-11-07 20:27
Starting with mod_python 3.4.1, req.add_cgi_vars() is no longer called
implicitly, and so must be called explicitly. It now includes
add_common_vars(), so there is no need to call add_common_vars()
separately. So - where you have req.add_common_vars() it should now be
req.add_cgi_vars(). (And if you'd like to maintain backwards
compatibility with older mod_python versions, simply call them both).
msg4944 Author: [hidden] (ber) Date: 2013-11-11 08:36
Grisha,
thanks for the report!

Right now I don't think roundup is already Python3 ready?
Or did it work for you?

Anyway, we appreciate any help or patches!


Best Regards,
Bernhard
msg4946 Author: [hidden] (grisha) Date: 2013-11-11 15:59
Bernard

This isn't about Python 3, just the new version of mod_python which was
released last month. We had someone complain about a roundup problem
with it, and that was the issue.

Grisha
msg4947 Author: [hidden] (ber) Date: 2013-11-12 07:56
Grisha,
ah, yes, sorry, I've have been reading it too fast.
Do you have a patch or a simple way to reproduce?
(This is the easiest way to get this into upstream.)
msg4948 Author: [hidden] (grisha) Date: 2013-11-12 17:52
Reproduce: 

Install Roundup with mod_python 3.4.1 or later, and you will get:
File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line
1211, in write_html
if self.env['REQUEST_METHOD'] == 'HEAD':
KeyError: 'REQUEST_METHOD'

The fix:

--- roundup//cgi/apache.py~     2013-03-28 05:50:18.000000000 -0400
+++ roundup/cgi/apache.py       2013-11-12 12:51:25.227114199 -0500
@@ -119,6 +119,7 @@
                 __tracker_cache_lock.release()
     # create environment
     # Note: cookies are read from HTTP variables, so we need all HTTP vars
+    req.add_cgi_vars()
     req.add_common_vars()
     _env = dict(req.subprocess_env)
     # XXX classname must be the first item in PATH_INFO.  roundup.cgi does:
msg5706 Author: [hidden] (rouilj) Date: 2016-07-02 17:49
See also: https://github.com/grisha/mod_python/issues/13

Also:

  http://modpython.org/live/current/doc-html/pythonapi.html


I propose this fix:

    # Release 3.4 of mod_python uses add_cgi_vars() and depricates
    # add_common_vars. So try to use the add_cgi_vars and if it fails
    # with AttributeError because we are running an older mod_apache without
    # that function, fallback to add_common_vars.
    try:
        req.add_cgi_vars()
    except AttributeError:
        req.add_common_vars()

so we try to call only add_cgi_vars() which is the current preferred
method. If it fails because the function doesn't exist it should
raise and AttributeError at which point we call the older add_common_vars.

Bern, does this look reasonable?

I don't have a suitable apache/mod_python environment to test,
but this sees pretty safe and matches recommendations from mod_python.

-- rouilj
msg5736 Author: [hidden] (ber) Date: 2016-07-04 07:53
John,
looks okay to me, just from looking at it.

Overall it probably needs a test with a regular and a new version.
Maybe you can win somebody else for doing the testing.

Best,
Bernhard
msg6672 Author: [hidden] (rouilj) Date: 2019-10-02 21:26
I have applied my suggested patch to apache.py. Updated header comments
to report that mod_python is deprecated for roundup 2.0, and may onl
work with python 2.
History
Date User Action Args
2019-10-02 21:26:29rouiljsetstatus: open -> closed
resolution: accepted
messages: + msg6672
2016-07-04 07:53:27bersetmessages: + msg5736
2016-07-02 17:49:42rouiljsetstatus: new -> open
assignee: rouilj
2016-07-02 17:49:25rouiljsetnosy: + rouilj
messages: + msg5706
2016-06-27 04:04:34rouiljsetkeywords: + patch
2014-07-22 06:16:38jerrykansetnosy: + jerrykan
2013-11-12 17:52:58grishasetmessages: + msg4948
2013-11-12 07:56:50bersetmessages: + msg4947
2013-11-11 15:59:53grishasetmessages: + msg4946
2013-11-11 08:36:51bersetnosy: + ber
messages: + msg4944
2013-11-07 20:27:24grishacreate