Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod_python error: "PythonHandler roundup.cgi.apache" #13

Closed
huskier opened this issue Nov 5, 2013 · 10 comments
Closed

Mod_python error: "PythonHandler roundup.cgi.apache" #13

huskier opened this issue Nov 5, 2013 · 10 comments
Labels

Comments

@huskier
Copy link

huskier commented Nov 5, 2013

Now mptest works fine, but when I use mod_python to configure roundup bug tracker, I've got the following error in browers [I tried Chrome, Firefox, and IE]:

Mod_python error: "PythonHandler roundup.cgi.apache"
Traceback (most recent call last):
File "/usr/lib64/python2.6/site-packages/mod_python/apache.py", line 398, in HandlerDispatch
result = obj(req)
File "/usr/lib/python2.6/site-packages/roundup/cgi/apache.py", line 135, in handler
_client.main()
File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 362, in main
self.inner_main()
File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 550, in inner_main
self.write_html(html)
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'

I've also tried to google the internet, but nothing useful available for this kind of error.

The apache error log gives:
[Tue Nov 05 10:24:37 2013] [notice] mod_python: (Re)importing module 'roundup.cgi.apache'
[Tue Nov 05 02:24:38 2013] [error] [client 119.78.238.228] PythonHandler roundup.cgi.apache: Traceback (most recent call last):, referer: http://119.78.238.228/roundup/
[Tue Nov 05 02:24:38 2013] [error] [client 119.78.238.228] PythonHandler roundup.cgi.apache: File "/usr/lib64/python2.6/site-packages/mod_python/apache.py", line 398, in HandlerDispatch\n result = obj(req), referer: http://119.78.238.228/roundup/
[Tue Nov 05 02:24:38 2013] [error] [client 119.78.238.228] PythonHandler roundup.cgi.apache: File "/usr/lib/python2.6/site-packages/roundup/cgi/apache.py", line 135, in handler\n _client.main(), referer: http://119.78.238.228/roundup/
[Tue Nov 05 02:24:38 2013] [error] [client 119.78.238.228] PythonHandler roundup.cgi.apache: File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 362, in main\n self.inner_main(), referer: http://119.78.238.228/roundup/
[Tue Nov 05 02:24:38 2013] [error] [client 119.78.238.228] PythonHandler roundup.cgi.apache: File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 550, in inner_main\n self.write_html(html), referer: http://119.78.238.228/roundup/
[Tue Nov 05 02:24:38 2013] [error] [client 119.78.238.228] PythonHandler roundup.cgi.apache: File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 1211, in write_html\n if self.env['REQUEST_METHOD'] == 'HEAD':, referer: http://119.78.238.228/roundup/
[Tue Nov 05 02:24:38 2013] [error] [client 119.78.238.228] PythonHandler roundup.cgi.apache: KeyError: 'REQUEST_METHOD', referer: http://119.78.238.228/roundup/

Thanks!

@grisha
Copy link
Owner

grisha commented Nov 5, 2013

Could you paste the relevant part of your Apache config?

@huskier
Copy link
Author

huskier commented Nov 5, 2013

The Apache config for roundup part is as following, and I copy the code from the roundup website, and change the directory according to my system. I use "//" instead of "#" for comments, otherwise, the format is weried.
#################################################
// Roundup Issue tracker
###############begin###########################
//enable Python optimizations (like 'python -O')
PythonOptimize On
//let apache handle static files from 'html' directories
AliasMatch /roundup/(.+)/@@file/(.) /var/www/html/roundup/$1/html/$2
//everything else is handled by roundup web UI
AliasMatch /roundup/([^/]+)/(?!@@file/)(.
) /var/www/html/roundup/$1/dummy.py/$2
//roundup requires a slash after tracker name - add it if missing
//RedirectMatch permanent ^/roundup/([^/]+)$ /roundup/$1/

//common settings for all roundup trackers
<Directory /var/www/html/roundup/issues>
Order allow,deny
Allow from all
AllowOverride None
Options None
AddHandler python-program .py
PythonHandler roundup.cgi.apache
//uncomment the following line to see tracebacks in the browser
//(note that some tracebacks will be displayed anyway)
PythonDebug On

//roundup tracker homes
<Directory /var/www/html/roundup/issues>
PythonOption TrackerHome /var/www/html/roundup/issues

###############end###########################

The tree command displays the roundup directory structure.
roundup/
└── issues
├── config.ini
├── config.ini~
├── db
│   ├── backend_name
...........................

Thanks for your help.

@grisha
Copy link
Owner

grisha commented Nov 5, 2013

I would say this is a bug in roundup, line 122 in this http://sourceforge.net/p/roundup/code/ci/default/tree/roundup/cgi/apache.py should be:

req.add_cgi_vars()

@huskier
Copy link
Author

huskier commented Nov 7, 2013

Thanks grisha.

This only partially solved the problem. After I changed the line reg.add_common_vars() to req.add_cgi_vars(), I can access the website http://119.78.238.228/roundup/issues/. However, the same error occured again after I clicked the links at random on the site http://119.78.238.228/roundup/issues/. Then, I restart httpd service again. The website is normal again for only a short time. again and again...

I changed the roundup 1.4.20 to 1.5.0, but the problem is still there. Your solution cures the problem for a short while.

very weried!

The error is a little different from the previous one. Here it is.

Mod_python error: "PythonHandler roundup.cgi.apache"
Traceback (most recent call last):
File "/usr/lib64/python2.6/site-packages/mod_python/apache.py", line 398, in HandlerDispatch
result = obj(req)
File "/usr/lib/python2.6/site-packages/roundup/cgi/apache.py", line 135, in handler
_client.main()
File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 367, in main
self.inner_main()
File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 567, in inner_main
self.write_html(html)
File "/usr/lib/python2.6/site-packages/roundup/cgi/client.py", line 1274, in write_html
if self.env['REQUEST_METHOD'] == 'HEAD':
KeyError: 'REQUEST_METHOD'

@grisha
Copy link
Owner

grisha commented Nov 7, 2013

Are you sure you simply didn't forget to make the same change when you upgraded to 1.5.0?

@huskier
Copy link
Author

huskier commented Nov 7, 2013

Absolutely sure.

Since the solution is not perfectly solve the problem in 1.4.20, I update the roundup to 1.5.0. If I don't make the change, the roundup application just would not work. After the updating, I modified the file /usr/lib/python2.6/site-packages/roundup/cgi/apache.py line 122 to req.add_cgi_vars(). The roundup app works, but only for a short time. I mean, the same error occurs again after I click some links randomly on the issues tracker website. Then, I have to restart httpd service. Then, I can access the issues tracker site again...

Strange.

@grisha
Copy link
Owner

grisha commented Nov 7, 2013

I don't have any ideas... It appears that self.env is getting modified somehow... It'd be interesting to try to see what is in self.env just before this happens. You could do this by inserting something like just before the if self.env['REQUEST_METHOD'] == 'HEAD' line :

if 'REQUEST_METHOD' not in self.env:
    raise Exception(self.env)

The content of env should appear in the error traceback then.

@grisha
Copy link
Owner

grisha commented Nov 7, 2013

Okay, I went ahead and installed a little test roundup set up, version 1.5, and it seems to work just find for me (with the req.add_cgi_vars() change), both mod_python 3.4.1 and 3.5.x branch (Python 2.7.5). I've clicked and reloaded pages and I do not get any errors. Another theory I have is that you may have some kind of a python path confusion whereby an older version of roundup apache.py gets loaded, which doesn't have the req.add_cgi_vars(). Your Python is 2.6, but I don't think that should make any difference.

@huskier
Copy link
Author

huskier commented Nov 8, 2013

I tried many times, the problem is still there. Maybe I need to update my Python to 2.7.5 manually, and meantime enable apache with thread support.
LD_PRELOAD=/lib/libpthread.so.0
export LD_PRELOAD

Frustrating!

I will let you know if I get around the problem. Thanks!

@grisha
Copy link
Owner

grisha commented Nov 12, 2013

I'm closing this issue since we don't know what the problem is - feel free to re-open if you figure it out.

@grisha grisha closed this as completed Nov 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants