#554 closed defect (fixed)
Attachments doesn't work with mod_python and windows
Reported by: | Owned by: | Christopher Lenz | |
---|---|---|---|
Priority: | normal | Milestone: | 0.10 |
Component: | web frontend/mod_python | Version: | 0.9.3 |
Severity: | major | Keywords: | mod_python attachments windows wsgi |
Cc: | rhind@…, nunterberg@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
The attachments page does not work for me under the following configuration:
- W2K server, Apache 2.0.48, Python 2.3.4, mod_python 3.1.3
When you select a file and fill out the description field and press 'Add' the page resets all fields to blank, but the file is not attached.
If I switch to cgi, everything works fine.
Attachments (3)
Change History (51)
comment:1 by , 20 years ago
Milestone: | → 0.8 |
---|---|
Priority: | normal → highest |
Severity: | normal → critical |
comment:2 by , 20 years ago
Component: | general → mod_python frontend |
---|
comment:3 by , 20 years ago
comment:4 by , 20 years ago
Status: | new → assigned |
---|
comment:5 by , 20 years ago
I'm starting to wonder if this is a Windows-server-only-thing or a windows-server-and-IE-don't-behave-together thing. I'll check with some different browsers and see where I get to.
comment:6 by , 20 years ago
OK - tried two different configurations, 0.7-stable, and trunk Head (828) with IE 6 & Firefox 0.92, and I'm getting the same problem, as described in the original posting of the ticket. TracURIRoot is set. Full configuration below:
Config 1 ========
Server: Windows XP SP1, Apache 2.0.48 (Win32) / mod_python 3.1.1 / Python 2.3.4 Trac: 0.7-stable branch HEAD revision (805) Client: Windows XP SP1 (same box as server), Web Browser: IE 6.0.2800 & Firefox 0.9.2
Apache Config:
# TRAC Config
Alias /trac "c:/Python23/share/trac/htdocs"
<Directory "c:/Python23/share/trac/htdocs">
Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all
</Directory>
<Location "/cgi-bin/trac.cgi">
SetEnv TRAC_ENV "c:\temp\trac\test-0.7-stable"
</Location>
<LocationMatch /tracproj>
SetHandler mod_python PythonHandler trac.ModPythonHandler PythonOption TracUriRoot /tracproj PythonOption TracEnvParentDir "c:\temp\trac"
Config 2 ========
Server: Windows XP SP1, Apache 2.0.48 (Win32) / mod_python 3.1.1 / Python 2.3.4 Trac: trunk HEAD revision (828) Client: Windows XP SP1 (same box as server), Web Browser: IE 6.0.2800 & Firefox 0.9.2
Apache Config
# TRAC Config
Alias /trac "c:/Python23/share/trac/htdocs"
<Directory "c:/Python23/share/trac/htdocs">
Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all
</Directory>
<Location "/cgi-bin/trac.cgi">
SetEnv TRAC_ENV "c:\temp\trac\test-trunk"
</Location>
<LocationMatch /tracproj>
SetHandler mod_python PythonHandler trac.ModPythonHandler PythonOption TracUriRoot /tracproj PythonOption TracEnvParentDir "c:\temp\trac"
comment:7 by , 20 years ago
Config in last comment was a right formatting mess. Try again:
Config 1 ======== Server: Windows XP SP1, Apache 2.0.48 (Win32) / mod_python 3.1.1 / Python 2.3.4 Trac: 0.7-stable branch HEAD revision (805) Client: Windows XP SP1 (same box as server), Web Browser: IE 6.0.2800 & Firefox 0.9.2 URL accessed for mod_python test: http://localhost:9877/tracproj/test-0.7-stable Apache Config: # TRAC Config Alias /trac "c:/Python23/share/trac/htdocs" <Directory "c:/Python23/share/trac/htdocs"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <Location "/cgi-bin/trac.cgi"> SetEnv TRAC_ENV "c:\temp\trac\test-0.7-stable" </Location> <LocationMatch /tracproj> SetHandler mod_python PythonHandler trac.ModPythonHandler PythonOption TracUriRoot /tracproj PythonOption TracEnvParentDir "c:\temp\trac" </LocationMatch> Config 2 ======== Server: Windows XP SP1, Apache 2.0.48 (Win32) / mod_python 3.1.1 / Python 2.3.4 Trac: trunk HEAD revision (828) Client: Windows XP SP1 (same box as server), Web Browser: IE 6.0.2800 & Firefox 0.9.2 URL accessed for mod_python test: http://localhost:9877/tracproj/test-trunk Apache Config # TRAC Config Alias /trac "c:/Python23/share/trac/htdocs" <Directory "c:/Python23/share/trac/htdocs"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <Location "/cgi-bin/trac.cgi"> SetEnv TRAC_ENV "c:\temp\trac\test-trunk" </Location> <LocationMatch /tracproj> SetHandler mod_python PythonHandler trac.ModPythonHandler PythonOption TracUriRoot /tracproj PythonOption TracEnvParentDir "c:\temp\trac" </LocationMatch>
comment:8 by , 20 years ago
Ok, seems to be a win32-only problem. I'll try to dig up a win32 box to test this on…
comment:9 by , 20 years ago
Keywords: | win32 added |
---|
comment:10 by , 20 years ago
Status: | assigned → new |
---|
comment:11 by , 20 years ago
Summary: | Attachments don't attach when using mod_python as of 0.7-stable revision 744 → Attachments doesn't work with mod_python and windows |
---|
I need help by some windows hacker to debug and fix this one.
comment:12 by , 20 years ago
I've just spent a few hours going through a debug session and found that this bug is caused by a bug in mod_python's util.py file!
They have patched it in their CVS. It should be broken on all platforms, not just Windows.
I'll also include the patch here.
comment:13 by , 20 years ago
Actually after further investigation it's actually a feature of Python 2.2 & 2.3! The mod_python patch is a workaround. I don't think it's going to be possible to make a patch to Trac to workaround the problem either so we may just have to document this issue for Python.
Python 2.1 doesn't have this problem because yo have to use the earlier mod_python.
comment:14 by , 20 years ago
I've just tested the patch on our test server and attachments finally work!
Jonas, Paul - thank you very much for putting the time and effort in to resolve this problem.
I've updated the ModPython wiki page with a note on this.
comment:15 by , 20 years ago
Milestone: | 0.8 → 0.9 |
---|
Good work Ian. I'm moving this ticket to 0.9 now because there's no point in blocking a 0.8 release just for this. But I think this ticket should stay open until a upstream version of modpython containing this patch has been released…
comment:16 by , 20 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This will hopefully not succeed?!
comment:17 by , 20 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:18 by , 20 years ago
Version: | 0.7.1 → 0.8 |
---|
Even with the util.py patch attachments didn't work for me on Apache/2.0.52 (Win32) mod_python/3.1.3 Python/2.3.4. and Trac-0.8-stable.
comment:19 by , 20 years ago
Cc: | added |
---|
They don't work for me either, win32, apache-2.0.52, mod-python 3.1.3, python-2.3.4
comment:21 by , 20 years ago
Ok, after thoroughly reading this thread, I realise I have to patch util.py that comes with mod_python. I have applied the patch, but how do I re-generate util.pyc and util.pyo. when I try with python, I get an error saying no module named _apache for the 'import _apache' line. Apparently this module is defined in mod_python loaded by apache.
So in that case, how do we re-compile the patched util.py?
comment:22 by , 20 years ago
Ok, I know nothing about python. I had a permissions problem. I generated the patched file through cygwin and it changed the permissions on util.py (cygwin never gives SYSTEM any permissions) which caused apache not to be able to read the file.
Changed the permissions to give SYSTEM full control fixed it and I can now attach files.
Cheers
Russell
comment:23 by , 19 years ago
The problem is still there on 0.8.4 using mod_python with Apache 2.0.54. I already assignen all permission for to the SYSTEM account and it still doesn't work.
Help!
Matthias.
comment:24 by , 19 years ago
This is a mod_python problem, not Trac, so upgrading your Trac version is not going to fix it. You need to apply the patch attached to this ticket. The problem with SYSTEM permissions was simply that in the process of applying the patch he accidentally changed the permissions on the file as well.
comment:25 by , 19 years ago
Worksforme. Now I'm using svn-HEAD of Trac with apache-2.0.54 and patch for util.py. The patch works well since 2004/12 (0.8.1?) until today (0.9pre). What is the problem? What does apache log says on fail?
comment:26 by , 19 years ago
Trac Environment:
- Windows XP Pro
- Apache 2.0.53
- mod_python 3.1.3
- Subversion 1.1.4
- pysqlite 1.1.6
I've been running 0.8.4 smoothly for a couple of months now on a test basis, including successfully applying and using the patch to util.py called for here. I've just upgraded to 0.9.1b and have run into problem with new and existing attachments.
For existing attachments, behavior depends on the type of file attached. .txt or .gif files are displayed correctly on the attachement page. However, on the attachment page there is no link to the attached file itself and, therefore, no way to download that file. For a word document or powerpoint file, for example, the attachment page has nothing displayed and no link to a file I might download.
For new attachments, browsing to a file to attach appears to work, but the end result is the same as described above for existing attachments.
comment:27 by , 19 years ago
Worked for me today.
Running Windows Small Business Server 2003 with Trac 0.9b1, mod_python 3.1.3
comment:28 by , 19 years ago
Version: | 0.8 → 0.9b1 |
---|
I found new problem about attachment. My server: Windows XP SP1 Apache 2.0.54 Python 2.3.5 svn 1.2.1 mod_python 3.1.3
trac 0.9b1
I want to add a new attachment, and after I fill the filename and clicked the Add button, I get this error:
Oops… Trac detected an internal error: 'StringField' object has no attribute 'filename'If you think this really should work and you can reproduce it. Then you should consider to report this problem to the Trac team.
Go to http://trac.edgewall.com/ and create a new ticket where you describe the problem, how to reproduce it. Don't forget to include the python traceback found below.
TracGuide — The Trac User and Administration Guide
Python traceback Traceback (most recent call last):
File "D:\develop\Python\2.3\Lib\site-packages\trac\web\modpython_frontend.py", line 205, in handler
dispatch_request(mpr.path_info, mpr, env)
File "D:\develop\Python\2.3\Lib\site-packages\trac\web\main.py", line 139, in dispatch_request
dispatcher.dispatch(req)
File "D:\develop\Python\2.3\Lib\site-packages\trac\web\main.py", line 107, in dispatch
resp = chosen_handler.process_request(req)
File "D:\develop\Python\2.3\lib\site-packages\trac\attachment.py", line 265, in process_request
self._do_save(req, attachment)
File "D:\develop\Python\2.3\lib\site-packages\trac\attachment.py", line 296, in _do_save
if not upload.filename:
AttributeError: 'StringField' object has no attribute 'filename'
I found that the upload just get the file content not the attachment form data. Is it a bug of mod_python? or trac?
comment:30 by , 19 years ago
comment:31 by , 19 years ago
I was having an issue where I wasn't able to upload files even after applying the patch to mod_python.
The following error message was being logged by Apache:
Exception exceptions.RuntimeError: 'instance.__dict__ not accessible in restricted mode' in ignored Exception exceptions.RuntimeError: 'instance.__dict__ not accessible in restricted mode' in ignored Exception exceptions.RuntimeError: 'instance.__dict__ not accessible in restricted mode' in ignored [Fri Sep 23 11:27:02 2005] [notice] Child 1488: Child process is exiting
Upon further investigation I found it was just files that were larger than the max limit set in trac.ini.
The weird part is the message telling me this didn't display on my regular machine, but only in the VPC where I was running the test install of Trac.
I altered the limit in the trac.ini file and it now works for me.
Hope this helps someone.
Apache/2.0.54 (Win32) SVN/1.2.3 mod_python/3.1.3 Python/2.3.5 Windows 2003 (in VPC) Trac/9.1b
comment:32 by , 19 years ago
Cc: | added |
---|
comment:33 by , 19 years ago
New ticket raised against jim@… comment as #2144 as I believ this is a different issue.
comment:34 by , 19 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
I finally got Apache installed on my windows machine (using XAMPP for windows) and I could reproduce the issue:
Traceback (most recent call last): File "D:\Workspace\install\lib\python\trac\devel\Lib\site-packages\trac\web\modpython_frontend.py", line 206, in handler dispatch_request(mpr.path_info, mpr, env) File "D:\Workspace\install\lib\python\trac\devel\Lib\site-packages\trac\web\main.py", line 139, in dispatch_request dispatcher.dispatch(req) File "D:\Workspace\install\lib\python\trac\devel\Lib\site-packages\trac\web\main.py", line 107, in dispatch resp = chosen_handler.process_request(req) File "D:\Workspace\install\lib\python\trac\devel\Lib\site-packages\trac\attachment.py", line 265, in process_request self._do_save(req, attachment) File "D:\Workspace\install\lib\python\trac\devel\Lib\site-packages\trac\attachment.py", line 296, in _do_save if not upload.filename:
The above was without the attachment:util_py.patch
Now, with the patch applied:
$ cd $PYTHONHOME/Lib/site-packages/mod_python $ cp util.py util.py-orig $ rm util.pyc $ rm util.pyo $ patch < util_py.patch (Stripping trailing CRs from patch.) patching file util.py
… the problem is gone.
I'll try to have a look if we can do something about that from within Trac (i.e. without the patch). At least some kind of warning could be produced.
comment:35 by , 19 years ago
Status: | new → assigned |
---|
I propose to issue the following warning:
-
attachment.py
293 293 req.redirect(attachment.parent_href) 294 294 295 295 upload = req.args['attachment'] 296 if not hasattr(upload, 'file'): 297 raise TracError('Attachment won\'t work with this version of ' 298 'ModPython. See <a href="%s">%s</a>.' \ 299 % ('http://projects.edgewall.com/trac/wiki/' 300 'TracModPython#Win32Issues', 301 'TracModPython / Win32 issues')) 296 302 if not upload.filename: 297 303 raise TracError, 'No file uploaded' 298 304 if hasattr(upload.file, 'fileno'):
Also, the targeted documentation (TracModPython#Win32Issues) has been expanded a bit.
comment:36 by , 19 years ago
Do you know if the issue is fixed for 3.2.2 which is now in beta? (I'm not planning on upgrading to the beta, but just wondered for when 3.2.2 final is released)?
Thanks
Russell
comment:37 by , 19 years ago
Not tested, but yes, the fix is in the trunk as well as in the 3-2-3b tag, which means that this specific problem will be solved in the 3.2.x line.
Of course, there might be other problems with Trac and mod_python 3.2.x, so an upgrade is not the recommended solution at this point.
comment:38 by , 19 years ago
Milestone: | 0.9 |
---|---|
Priority: | highest → high |
Severity: | critical → major |
Ok, we decided to postpone closing this ticket at the time mod_python 3.2.x will be release and becomes the recommended version to use for Trac.
In the meantime, the issue is now well documented.
by , 19 years ago
comment:39 by , 19 years ago
just as an update, I have tried using trac-0.9.2 with mod-python-3.2.5b on win2k server and it doesn't seem to work.
I examined the util.py file included on mod-python-3.2.5b and it appears to already include the added lines from the patchfile.
When I try to upload a file I get an: Error No file uploaded.
page.
comment:40 by , 19 years ago
nevermind, it appears to be working with binary files.
tried with an .exe file and it uploaded fine.
however an empty .txt file produced the error.
seems to be working.
comment:41 by , 19 years ago
Priority: | high → normal |
---|---|
Version: | 0.9b1 → 0.9.3 |
I am using Apache 2.0.55, Python 2.3.5, Trac 0.9.3 and get the message 'StringField' object has no attribute 'filename'
here is the traceback:
Traceback (most recent call last): File "C:\Python23\Lib\site-packages\trac\web\modpython_frontend.py", line 206, in handler dispatch_request(mpr.path_info, mpr, env) File "C:\Python23\Lib\site-packages\trac\web\main.py", line 139, in dispatch_request dispatcher.dispatch(req) File "C:\Python23\Lib\site-packages\trac\web\main.py", line 107, in dispatch resp = chosen_handler.process_request(req) File "C:\Python23\Lib\site-packages\trac\attachment.py", line 267, in process_request self._do_save(req, attachment) File "C:\Python23\Lib\site-packages\trac\attachment.py", line 298, in _do_save if not upload.filename: AttributeError: 'StringField' object has no attribute 'filename'
i tried to copy the util.py inte the mod_python directory, but nothing changed.
i am pretty new to python, so what else can i check to be sure, i have done everything right?
comment:42 by , 19 years ago
I've just re-installed our server because of a drive crash, and am now running with apache 2.0.55 and got the same error. I replaced util.py.
Did you restart the web server? You might also need to delete the util.pyc and util.pyo files too (not too sure about that). After doing this, I can upload attachments.
Cheers
Russell
comment:43 by , 19 years ago
Keywords: | wsgi added |
---|---|
Milestone: | → 0.10 |
Owner: | changed from | to
Status: | assigned → new |
This whole problem is going to go away once the WSGI branch is migrated. If you have a chance, please try the branch out.
comment:44 by , 19 years ago
Is there a guide posted for how to use trac with WSGI? (Similar to TracModPython?) I would test it, but I think I'll have to wait until 0.10 comes out because I've currently only ever installed from the windows installers, don't actually known python myself so performing a manual installation from a branch is probably out of my scope for now.
Thanks
Russell
comment:45 by , 19 years ago
Replacing util.py, deleting util.pyc and util.pyo and restarting apache works fine.
Now i can upload attachments! Thanks for your fast replies!
comment:46 by , 19 years ago
http://www.modpython.org/ says: Feb-09-2006 3.2.7 is out and available on the download page.
That release contains the patch attached above. I have updated TracModPython#Win32Issues accordingly.
comment:47 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The WSGI branch was merged into trunk in [2957], so this issue should now be fixed.
comment:48 by , 18 years ago
Keywords: | windows added; win32 removed |
---|
Is this still the case?
I just tested attaching files with firefox and safari on 0.7-stable (rev 817) running os OSX and it seems to work.
You maybe need to set the TracUriRoot variable, see ModPython.