[PATCH] Inability to add/delete attachments to wiki pages
|Reported by:||Owned by:|
|Severity:||major||Keywords:||attachment action CGI parse|
today I stumbled upon on a rather strange problem with the attachment module, as it was ignoring POST requests that create new attachments on wiki pages, thus making impossible to add or remove them. I searched on the open issues here and found nothing relevant.
So, after much testing, tcpdumping, log inspection, etc, I started adding
self.env.log.debug() statements to identify where the execution flow was interrupted, and I found that the
action CGI parameter is incorrectly parsed somewhere, because instead of referencing a
str containing the action name, it contains a
list of 2 identical
str objects containing the action name. e.g.:
2009-06-10 21:19:57,386 Trac[attachment] DEBUG: action: [u'delete', u'delete']
The following patch fixes the issue, I don't know if it's a correct solution, but in the meantime it works on my installation; I'm quite sure that this problem should be corrected elsewhere. I'm no python expert, but sailing through the Trac sources was fun :).
--- attachment.py~ 2009-06-10 21:30:47.000000000 +0200 +++ attachment.py 2009-06-10 21:30:40.000000000 +0200 @@ -367,6 +367,9 @@ parent_realm = Resource(parent_realm) action = req.args.get('action', 'view') + if action.__class__ == list: + action = action + if action == 'new': parent_id = path.rstrip('/') else:
Python 2.6 and
Apache 2.2.11 on an Ubuntu 9.04 installation on
Cheers, and thanks for developing Trac and releasing it as OSS :).