Opened 20 years ago
Closed 20 years ago
#1370 closed defect (fixed)
Wiki Attachments failing with "Attachment Not Found" message as of rev. 1454
Reported by: | Owned by: | anonymous | |
---|---|---|---|
Priority: | normal | Milestone: | 0.9 |
Component: | web frontend/mod_python | Version: | devel |
Severity: | major | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
I'm running against svn trunk rev 1454. When attempting to create an attachment on a wiki page, I get an error message: "Attachment not found"
No traceback is visible on the webpage — I enabled file logging, and got this traceback in the log:
10:51:38 Trac[attachment] DEBUG: Trying to open attachment at /var/lib/trac/aos/attachments/wiki/SandBox 10:51:38 Trac[main] ERROR: Attachment not found 10:51:38 Trac[main] ERROR: Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/trac/web/modpython_frontend.py", line 168, in handler dispatch_request(mpr.path_info, mpr, env) File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 305, in dispatch_request module.render(req) File "/usr/lib/python2.3/site-packages/trac/attachment.py", line 63, in render self.render_view(req, parent_type, parent_id, filename) File "/usr/lib/python2.3/site-packages/trac/attachment.py", line 130, in render_view raise util.TracError('Attachment not found') TracError: Attachment not found
Attachments (1)
Change History (7)
comment:1 by , 20 years ago
comment:2 by , 20 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Version: | none → devel |
comment:3 by , 20 years ago
Description: | modified (diff) |
---|
The problem here is that the FieldStorage
implementation of mod_python behaves differently from the implementation in cgi.py
. While the latter adds query-string parameters after POST body parameters, and does so only if the the parameter isn't already in the body, the mod_python implementation adds query string parameters first and unconditionally.
While the mod_python implementation is IMHO correct, cgi.py
is the standard to follow. I'll attach a patch that modifies this behavior to make it compatible.
I believe this is preferrabe to hacking around the problem in the individual modules, because it decreases the probability of things failing in one frontend while working in another.
comment:4 by , 20 years ago
Version: | devel → none |
---|
Well, excuse this ticket for giving me a chance to learn, oh I don't know, a little python, trac request flow, clearsilver/hdf, etc. :)
The previous fix didn't work for Ticket attachments, only wiki attachments. This one works for both wiki and template attachments:
Index: templates/attachment.cs =================================================================== --- templates/attachment.cs (revision 1456) +++ templates/attachment.cs (working copy) @@ -9,7 +9,7 @@ <?cs if:attachment.mode == 'new' ?> <h1>Add Attachment to <a href="<?cs var:attachment.parent_href?>"><?cs var:attachment.parent_name ?></a></h1> - <form id="attachment" method="post" enctype="multipart/form-data" action=""> + <form id="attachment" method="post" enctype="multipart/form-data" action="<?cs var:cgi_location?>/attachment/<?cs var:attachment.parent_type?>/<?cs var:attachment.parent_id?>"> <div class="field"> <label>File:<br /><input type="file" name="attachment" /></label> </div>
This still feels a bit naive, but should get the job done for nwo.
by , 20 years ago
Attachment: | mpfrontend_fix.patch added |
---|
Workaround in mod_python handler to unify handling of GET vs. POST parameters with cgi.py
comment:6 by , 20 years ago
Component: | wiki → mod_python frontend |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Fix committed in [1467].
After some hacking around, I think I've found the solution. (it's in the attachment template). The attach form was submitting to the "current" url (<form … action="">), but that url had a paramter of "?action=new". The form itself had a hidden value of action=save (which is the correct one). The attachment code was getting both values in the action value, and was never executing the path for 'save'.
Anyway, I've updated the form action parameter, and this seems to have solved the problem. Here's a diff for what I changed: