Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

Last modified 15 years ago

#2137 closed defect (wontfix)

Trac fails on windows with mod_python

Reported by: Gytis Raciukaitis <gytis@…> Owned by: Jonas Borgström
Priority: normal Milestone:
Component: web frontend/mod_python Version: 0.9.4
Severity: major Keywords: None
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

The error reported looks like this:

[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend: Traceback (most recent call last):
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "C:\\Python23\\Lib\\site-packages\\mod_python\\apache.py", line 299, in HandlerDispatch\n    result = object(req)
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "C:\\Python23\\Lib\\site-packages\\trac\\web\\modpython_frontend.py", line 199, in handler\n    env = get_environment(mpr, project_opts)
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "C:\\Python23\\Lib\\site-packages\\trac\\web\\main.py", line 338, in get_environment\n    return _open_environment(env_path, threaded)
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "C:\\Python23\\Lib\\site-packages\\trac\\web\\main.py", line 51, in _open_environment\n    env_cache[env_path] = open_environment(env_path)
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "C:\\Python23\\lib\\site-packages\\trac\\env.py", line 354, in open_environment\n    env = Environment(env_path)
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "C:\\Python23\\lib\\site-packages\\trac\\env.py", line 77, in __init__\n    from trac.loader import load_components
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "C:\\Python23\\lib\\site-packages\\trac\\loader.py", line 20, in ?\n    import pkg_resources
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "c:\\python23\\lib\\site-packages\\setuptools-0.6a2-py2.3.egg\\pkg_resources.py", line 2146, in ?\n    working_set = WorkingSet()
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "c:\\python23\\lib\\site-packages\\setuptools-0.6a2-py2.3.egg\\pkg_resources.py", line 343, in __init__\n    self.add_entry(entry)
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "c:\\python23\\lib\\site-packages\\setuptools-0.6a2-py2.3.egg\\pkg_resources.py", line 358, in add_entry\n    for dist in find_distributions(entry, True):
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend:   File "c:\\python23\\lib\\site-packages\\setuptools-0.6a2-py2.3.egg\\pkg_resources.py", line 1372, in find_on_path\n    for entry in os.listdir(path_item):
[Wed Sep 28 11:15:20 2005] [error] [client 192.168.0.151] PythonHandler trac.web.modpython_frontend: WindowsError: [Errno 123] The filename, directory name, or volume label syntax is incorrect: '\\\\\\\\*.*'

Looking deeper into it i found out that sys.path[0] is the problem, because it is initialized to "/". I fixed the problem locally by removing this element from sys.path in env.py.

Attachments (1)

trac_trunk_r2639_setuptools_win.patch (716 bytes ) - added by Gytis Raciukaitis <gytis@…> 19 years ago.
Crude fix to the problem

Download all attachments as: .zip

Change History (14)

by Gytis Raciukaitis <gytis@…>, 19 years ago

Crude fix to the problem

comment:1 by Gytis Raciukaitis <gytis@…>, 19 years ago

I added crude fix to the problem due to several requests to do so. It may not be a perfect one since i'm not Python guru but it works at least.

comment:2 by Emmanuel Blot, 19 years ago

Component: search systemgeneral
Milestone: 0.7.1
Priority: lowestnormal
Severity: minorcritical
Version: 0.8devel

(reverting back to the original settings)

comment:3 by Matthew Good, 19 years ago

Resolution: wontfix
Status: newclosed

This seems like a setuptools bug, not something that is a Trac problem. If it still occurs with the latest setuptools it should be reported there.

comment:4 by franetic, 19 years ago

Milestone: 0.9.5
Resolution: wontfix
Severity: blockernormal
Status: closedreopened
Summary: Setuptools fail on windows with mod_pythonTrac fails on windows with mod_python
Type: taskdefect
Version: 0.7.10.9.4

It seems for me it is not (just?) a problem with the setuptools. After upgrading Trac (like from 092 to 093 or from 093 to 094) to a new version the apache logs the following errors on the first request:

[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend: Traceback (most recent call last):, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\lib\\site-packages\\mod_python\\apache.py", line 299, in HandlerDispatch\n    result = object(req), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend: Traceback (most recent call last):, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\lib\\site-packages\\mod_python\\apache.py", line 299, in HandlerDispatch\n    result = object(req), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\modpython_frontend.py", line 199, in handler\n    env = get_environment(mpr, project_opts), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\main.py", line 335, in get_environment\n    return _open_environment(env_path, threaded), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\main.py", line 51, in _open_environment\n    env_cache[env_path] = open_environment(env_path), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\env.py", line 374, in open_environment\n    env = Environment(env_path), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\modpython_frontend.py", line 199, in handler\n    env = get_environment(mpr, project_opts), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\main.py", line 335, in get_environment\n    return _open_environment(env_path, threaded), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\main.py", line 51, in _open_environment\n    env_cache[env_path] = open_environment(env_path), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\env.py", line 374, in open_environment\n    env = Environment(env_path), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\env.py", line 85, in __init__\n    from trac.loader import load_components, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend: ImportError: cannot import name load_components, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\env.py", line 85, in __init__\n    from trac.loader import load_components, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend: ImportError: cannot import name load_components, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend: Traceback (most recent call last):, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\lib\\site-packages\\mod_python\\apache.py", line 299, in HandlerDispatch\n    result = object(req), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\modpython_frontend.py", line 199, in handler\n    env = get_environment(mpr, project_opts), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\main.py", line 335, in get_environment\n    return _open_environment(env_path, threaded), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\web\\main.py", line 51, in _open_environment\n    env_cache[env_path] = open_environment(env_path), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\env.py", line 374, in open_environment\n    env = Environment(env_path), referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend:   File "C:\\Python\\23\\Lib\\site-packages\\trac\\env.py", line 85, in __init__\n    from trac.loader import load_components, referer: http://pscm
[Mon Apr 03 12:03:39 2006] [error] [client xxx.xxx.xxx.xxx] PythonHandler trac.web.modpython_frontend: ImportError: cannot import name load_components, referer: http://pscm

The last ImportError repeats how many TracProject I have.

The index page falls back to the built-in one, the custom one fails to load probably due this error.

On the index page: name of the TracProject itself is correct, but the descrption is an error.

The first TracProject shows the error:

Error ([Errno 123] Die Syntax f? Dateinamen, Verzeichnisnamen oder die Datentr䧥rbezeichnung ist falsch: '\\\\*.*')

The rest shows:

Error (cannot import name load_components)

Applying the patch mentioned above to the env.py will fix and solve this issue.

So, it would be nice to incorporate this patch in an appropriate way into the source.

I run Trac on Win2k3 with mod_python.

comment:5 by franetic, 19 years ago

Component: ticket systemmod_python frontend

comment:6 by franetic, 19 years ago

Sorry, it does not fall back to the built-in index page… my bad. But the rest applies.

comment:7 by Matthew Good, 19 years ago

Resolution: wontfix
Status: reopenedclosed

The patch is a potential workaround, but I don't think it should be released with Trac because this problem needs to be fixed at its source. Either you have an invalid path in the PYTHONPATH environment variable, mod_python is modifying sys.path in an invalid way, or this needs fixed in setuptools. Please check your installation, and report the problem to mod_python or setuptools if necessary.

comment:8 by anonymous, 19 years ago

Thanks for pointing this out… I've made a little search:

As your function handle(req) in modpython_frontend is called the request object already contains the trouble: req.hlist.directory: "∧\"

The function HandlerDispatch() in Callback class appends this invalid directory to the sys.path.

I had mod_python 3.1.3… upgrading to 3.2 line solves the problem. (tried 3.2.5b, 3.2.8)

comment:9 by Emmanuel Blot, 18 years ago

Component: mod_python frontend
Milestone: 0.8
Priority: normal
Severity: criticalmajor
Type: defect
Version: 0.8.10.9.4

We definitely need a SpamFilter that rejects comments with too many URLs…

comment:11 by ebray, 16 years ago

Speaking of SpamFilter….

comment:13 by Christian Boos, 16 years ago

The above spam entries had a karma of 1. min_karma should be set to 2 (it's currently set to 0), as legitimate entries with a karma of 1 are very uncommon.

in reply to:  2006 comment:14 by yvDQWzPHoN, 15 years ago

Milestone: 0.12.1

doors.txt;10;15

comment:15 by Remy Blank, 15 years ago

Milestone: 0.12.1

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.