Modify

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#12539 closed defect (fixed)

AwesomeAttachmentsPlugin does not work with 1.0.6

Reported by: wbeaucha Owned by: Ryan J Ollos
Priority: normal Component: AwesomeAttachmentsPlugin
Severity: normal Keywords:
Cc: Trac Release: 1.0

Description

Installed and enabled AwesomeAttachmentsPlugin on 1.0.6.post2, running on windows 2008. The new dialog at the bottom of the new ticket page shows up and lets you choose files to attach, but when the ticket is submitted the files are not uploaded. Viewing the ticket shows 0 attachments.

Attachments (0)

Change History (42)

comment:1 Changed 8 years ago by Ryan J Ollos

Owner: set to Ryan J Ollos
Status: newaccepted

Did you disable trac.ticket.web_ui.TicketModule? See AwesomeAttachmentsPlugin#Installation.

comment:2 Changed 8 years ago by wbeaucha

Yes, I tried adding: trac.ticket.web_ui.TicketModule = disabled but when I did that the "New Ticket" menu button disappeared and when I clicked view tickets I got an error message.

comment:3 Changed 8 years ago by Ryan J Ollos

Did you copy the [components] section from AwesomeAttachmentsPlugin#Installation? I just noticed a typo, fixed in AwesomeAttachmentsPlugin@18.

comment:4 Changed 8 years ago by wbeaucha

Yes, I copied the [components] section from the install page. I re-added it after your typo fix and now the attachments add fine.

One other issue is that when I attach an image, AwesomeAttachmentsPlugin automatically adds the image code to the description field, but the syntax is wrong. It adds:

[[Image(C:\fakepath\my_image.png)]]

when it should be:

[[Image(my_image.png)]]

Thank you!

comment:5 Changed 8 years ago by Ryan J Ollos

In 14919:

0.3dev: Eliminate need to disable TicketModule.

A redirect listener is used to add the attachments. This should help to future-proof the plugin against changes in Trac because TicketModule._do_create is no longer re-implemented in the plugin.

  • Hide the "I have files to attach to this ticket" checkbox.
  • Remove tag_svn_revision, which is unsupported in setuptools >= 10.

Refs #12539.

comment:6 in reply to:  4 Changed 8 years ago by Ryan J Ollos

Replying to wbeaucha:

One other issue is that when I attach an image, AwesomeAttachmentsPlugin automatically adds the image code to the description field, but the syntax is wrong.

Yeah, I can reproduce that issue. I'll take a look.

Would you kindly test out the changes in [14919] and report back? Thanks!

comment:7 Changed 8 years ago by Ryan J Ollos

You'll need to re-enable trac.ticket.web_ui.TicketModule after updating to [14919].

Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:8 Changed 8 years ago by Ryan J Ollos

In 14920:

0.3dev: Remove C:\fakepath from filename used in Image macro.

Refs #12539.

comment:9 Changed 8 years ago by Ryan J Ollos

#7044 is the only open issue for this plugin, and I feel that it's fairly minor in Trac 1.0 and later. If your testing of the plugin goes well, then I'll tag version 0.3.

comment:10 Changed 8 years ago by Ryan J Ollos

Btw, I must give credit for the implementation in [14919] to jun66j5. I used the patch trac:attachment:ticket:11377:tracadvsearchplugin.diff as guidance in implementing the changes.

comment:11 Changed 8 years ago by Ryan J Ollos

comment:12 Changed 8 years ago by wbeaucha

I downloaded the latest packet from AwesomeAttachmentsPlugin, installed it using "easy_install ." and restarted trac. I removed the line that disabled trac.ticket.web_ui.TicketModule.

When I enable the AwesomeAttachmentsPlugin plugin from web admin, it adds: awesome.awesomeattachments.awesomeattachments = enabled. I created a ticket and added an attachment. I no longer see the "I have files to attach to this ticket" checkbox. I see that the Image macro code has been updated to [[Image(my_image.png)]].

The attachment does not get added.

comment:13 in reply to:  12 Changed 8 years ago by Ryan J Ollos

Replying to wbeaucha:

The attachment does not get added.

I'm not able to reproduce. Could you set the log level to debug (TracTroubleshooting#ChecktheLogs) and look at the output? Here is what I see:

09:20:29 Trac[main] DEBUG: Dispatching <RequestWithSession "POST '/newticket'">
09:20:29 Trac[api] WARNING: Unable to find repository '(default)' for synchronization
09:20:29 Trac[session] DEBUG: Retrieving session for ID '68b69fb027e096641b75d671'
09:20:29 Trac[attachment] INFO: New attachment: ticket:22: trac_logo.png by anonymous
127.0.0.1 - - [14/Oct/2015 09:20:29] "POST /newticket HTTP/1.1" 303 -
09:20:30 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/ticket/22'">
09:20:30 Trac[api] WARNING: Unable to find repository '(default)' for synchronization
09:20:30 Trac[session] DEBUG: Retrieving session for ID '68b69fb027e096641b75d671'
09:20:30 Trac[default_workflow] DEBUG: render_ticket_action_control: action "leave"
09:20:30 Trac[default_workflow] DEBUG: render_ticket_action_control: action "resolve"
09:20:30 Trac[default_workflow] DEBUG: render_ticket_action_control: action "reassign"
09:20:30 Trac[default_workflow] DEBUG: render_ticket_action_control: action "accept"
09:20:30 Trac[chrome] DEBUG: Prepare chrome data for request
09:20:30 Trac[formatter] DEBUG: Executing Wiki macro Image by provider <trac.wiki.macros.ImageMacro object at 0x109750950>
127.0.0.1 - - [14/Oct/2015 09:20:30] "GET /ticket/22 HTTP/1.1" 200 -
09:20:30 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/raw-attachment/ticket/22/trac_logo.png'">
09:20:30 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/chrome/site/your_project_logo.png'">
09:20:30 Trac[api] WARNING: Unable to find repository '(default)' for synchronization
09:20:30 Trac[chrome] WARNING: File your_project_logo.png not found in any of ['/Users/rjollos/ticket12529/trac/htdocs']
09:20:30 Trac[main] WARNING: [127.0.0.1] HTTPNotFound: 404 Not Found (File your_project_logo.png not found)
09:20:30 Trac[chrome] DEBUG: Prepare chrome data for request
09:20:30 Trac[session] DEBUG: Retrieving session for ID '68b69fb027e096641b75d671'
09:20:30 Trac[session] DEBUG: Retrieving session for ID '68b69fb027e096641b75d671'
09:20:30 Trac[attachment] DEBUG: Trying to open attachment at /Users/rjollos/ticket12529/trac/files/attachments/ticket/12c/12c6fc06c99a462375eeb3f43dfd832b08ca9e17/b0ceaa97b9745847ef52045f7146a042e65ba944.png
09:20:30 Trac[chrome] DEBUG: Prepare chrome data for request
127.0.0.1 - - [14/Oct/2015 09:20:30] "GET /raw-attachment/ticket/22/trac_logo.png HTTP/1.1" 200 -
127.0.0.1 - - [14/Oct/2015 09:20:30] "GET /chrome/site/your_project_logo.png HTTP/1.1" 404 -

comment:14 Changed 8 years ago by wbeaucha

Here's the log:

2015-10-14 12:27:34,229 Trac[main] DEBUG: Dispatching <RequestWithSession "POST '/newticket'">
2015-10-14 12:27:34,229 Trac[api] WARNING: Unable to find repository '(default)' for synchronization
2015-10-14 12:27:34,244 Trac[session] DEBUG: Retrieving session for ID u'tracadmin'
2015-10-14 12:27:34,651 Trac[default_workflow] DEBUG: render_ticket_action_control: action "leave"
2015-10-14 12:27:34,651 Trac[default_workflow] DEBUG: render_ticket_action_control: action "resolve"
2015-10-14 12:27:34,651 Trac[default_workflow] DEBUG: render_ticket_action_control: action "reassign"
2015-10-14 12:27:34,667 Trac[default_workflow] DEBUG: render_ticket_action_control: action "accept"
2015-10-14 12:27:34,808 Trac[formatter] DEBUG: Executing Wiki macro Image by provider <trac.wiki.macros.ImageMacro object at 0x02CBBA30>
2015-10-14 12:27:34,869 Trac[notification] INFO: Sending notification through SMTP at mail.comfin.ge.com:25 to [u'mail.addrress@zzz.com']
2015-10-14 12:27:36,151 Trac[main] DEBUG: Dispatching <RequestWithSession "POST '/newticket'">
2015-10-14 12:27:36,151 Trac[api] WARNING: Unable to find repository '(default)' for synchronization
2015-10-14 12:27:36,151 Trac[session] DEBUG: Retrieving session for ID u'tracadmin'
2015-10-14 12:27:36,197 Trac[chrome] DEBUG: Prepare chrome data for request
2015-10-14 12:27:37,338 Trac[main] DEBUG: Dispatching <RequestWithSession "GET '/ticket/66'">
2015-10-14 12:27:37,338 Trac[api] WARNING: Unable to find repository '(default)' for synchronization
2015-10-14 12:27:37,338 Trac[session] DEBUG: Retrieving session for ID u'tracadmin'
2015-10-14 12:27:37,683 Trac[formatter] DEBUG: Executing Wiki macro Image by provider <trac.wiki.macros.ImageMacro object at 0x02CBBA30>
2015-10-14 12:27:37,697 Trac[default_workflow] DEBUG: render_ticket_action_control: action "leave"
2015-10-14 12:27:37,697 Trac[default_workflow] DEBUG: render_ticket_action_control: action "resolve"
2015-10-14 12:27:37,697 Trac[default_workflow] DEBUG: render_ticket_action_control: action "reassign"
2015-10-14 12:27:37,713 Trac[default_workflow] DEBUG: render_ticket_action_control: action "accept"
2015-10-14 12:27:37,760 Trac[chrome] DEBUG: Prepare chrome data for request
2015-10-14 12:27:40,072 Trac[formatter] DEBUG: Executing Wiki macro Image by provider <trac.wiki.macros.ImageMacro object at 0x02CBBA30>
Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:15 Changed 8 years ago by wbeaucha

It looks like in our environment the path /chrome/awesome/js/awesome.js is not a valid URL path. It should be /trac/chrome/awesome/js/awesome.js . Does that need to be a relative path rather than absolute?

Thanks again

comment:16 in reply to:  15 Changed 8 years ago by Ryan J Ollos

Replying to wbeaucha:

It looks like in our environment the path /chrome/awesome/js/awesome.js is not a valid URL path. It should be /trac/chrome/awesome/js/awesome.js . Does that need to be a relative path rather than absolute?

That's an application-relative path, so the value shown is okay. Did you do a hard-refresh of your browser to clear the cached version of awesome.js? For the Chrome browser: SHIFT + F5 on Windows or CMD + R on Mac.

comment:17 Changed 8 years ago by Ryan J Ollos

In 14921:

0.3dev: Remove code that is unused after [14919].

Refs #12539.

comment:18 Changed 8 years ago by Ryan J Ollos

In 14922:

0.3dev: Fix error when attachment boxes are empty.

Refs #12539.

comment:19 Changed 8 years ago by Ryan J Ollos

In 14923:

0.3dev: Fix issue with FieldStorage evaluating to False.

Refs #12539.

comment:20 Changed 8 years ago by Ryan J Ollos

In 14924:

0.3dev: Allow file name with colon and backslash characters

This change is ported from [trac 11365] (trac:#10850).

Refs #12539.

comment:21 Changed 8 years ago by Ryan J Ollos

Would you mind testing again with [14924]?

comment:22 Changed 8 years ago by Ryan J Ollos

In 14925:

0.3dev: Replace unicode control codes with spaces in attachment filename

This incorporates changes from [trac 13603] (trac:#11395).

Trac 1.0 and later is now required.

Refs #12539.

comment:23 Changed 8 years ago by Ryan J Ollos

In 14926:

0.3dev: Require Trac >= 1.0.

Refs #12539.

comment:24 Changed 8 years ago by Ryan J Ollos

Relevant comment in trac:comment:9:ticket:11395.

comment:25 Changed 8 years ago by wbeaucha

I downloaded the latest, installed it, restarted trac and tried it with both Chrome and Firefox but still cannot get it to add the attachment. No errors but the ticket shows 0 attachments. I also verified that if I disable AwesomeAttachmentsPlugin I can still add an an attachment.

Last edited 8 years ago by wbeaucha (previous) (diff)

comment:26 Changed 8 years ago by Ryan J Ollos

If you don't see the I have files to attach to this ticket then it seems certain that awesome.js is loading, but just to be sure, could you view the source for the page and verify that you can follow a link to awesome.js?

Do you have any other plugins installed?

comment:27 Changed 8 years ago by wbeaucha

I have files to attach to this ticket is not displayed, and I can go to the URL and view the js with no issues. Apparently I have trac 1.09 installed, not 1.06 as mentioned previously. I do have a bunch of other plugins installed, but I created a trac.ini with only the following loaded to test and had the same results:

acct_mgr.admin.* = enabled
acct_mgr.api.* = enabled
acct_mgr.db.sessionstore = disabled
acct_mgr.htfile.htdigeststore = enabled
acct_mgr.http.* = disabled
acct_mgr.notification.* = enabled
acct_mgr.pwhash.* = enabled
acct_mgr.pwhash.htdigesthashmethod = enabled
acct_mgr.register.* = enabled
acct_mgr.svnserve.svnservepasswordstore = disabled
acct_mgr.web_ui.* = enabled
acct_mgr.web_ui.resetpwstore = disabled
awesomeattachments.* = enabled
awesome.awesomeattachments.awesomeattachments = enabled

comment:28 Changed 8 years ago by Ryan J Ollos

Okay, reproduced. The issue occurs with the environment name contained in the path. I had been running tracd with the -s switch, which strips the environment name from the path. Investigating a fix ...

comment:29 Changed 8 years ago by Ryan J Ollos

In 14927:

0.3dev: Don't apply pattern to start of string.

This fixes an issue in which the path would not be matched in _add_attachments when the url contained an environment prefix.

Refs #12539.

comment:30 Changed 8 years ago by Ryan J Ollos

Should be fixed now, finally!

comment:31 Changed 8 years ago by wbeaucha

That did it! Awesome.

Thanks again, this will make the users happy!

comment:32 Changed 8 years ago by Ryan J Ollos

Thanks for the fast reply. I'm happy to close this one! Actually, considering now whether we can integrate this into Trac without too much effort.

comment:33 Changed 8 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

In 14928:

0.3: Release version 0.3.

Fixes #12539.

comment:34 Changed 8 years ago by Ryan J Ollos

One thing to be aware of is that attachment manipulators are not called when inserting attachments from the /newticket page: awesomeattachmentsplugin/tags/awesomeattachments-0.3/awesome/awesomeattachments.py@:74#L74. To see this, compare to browser:tags/trac-1.0.9/trac/attachment.py@:744-754#L718. I might fix the issue, but first I'll look further into the possibility of integrating the equivalent of this plugin to Trac.

comment:35 in reply to:  29 Changed 8 years ago by Jun Omae

Replying to rjollos:

In 14927:

I don't think we intend to use TicketModule.ticket_path_re to search ticket's id from URL. The variable is for applying to req.path_info. Instead, I think we should declare own variable for this.

  • awesomeattachmentsplugin/trunk/awesome/awesomeattachments.py

    diff --git a/awesomeattachmentsplugin/trunk/awesome/awesomeattachments.py b/awesomeattachmentsplugin/trunk/awesome/awesomeattachment
    index 88d0cba..66bf04a 100644
    a b import unicodedata 
    1414
    1515from trac.attachment import Attachment
    1616from trac.core import Component, TracError, implements
    17 from trac.ticket.web_ui import TicketModule
    1817from trac.util import get_reporter_id
    1918from trac.util.text import stripws
    20 from trac.util.translation import _, tag_
     19from trac.util.translation import _
    2120from trac.web.api import IRequestFilter
    2221from trac.web.chrome import ITemplateProvider, add_link, add_script
    2322
    class AwesomeAttachments(Component): 
    6160
    6261    # Private methods
    6362
     63    _ticket_path_re = re.compile(r'/newticket/([0-9]+)$')
     64
    6465    def _add_attachments(self, req, url, permanent):
    65         match = TicketModule.ticket_path_re.search(url)
     66        match = self._ticket_path_re.search(url)
    6667        if match:
    6768            tid = match.group(1)
    6869            attachments = req.args.getlist('attachment[]')

Another considering, I think req.path_info.rstrip() == '/newticket' is redundant. We could simplify it with req.path_info == '/newticket'. See trac:source:/tags/trac-1.0.9/trac/ticket/web_ui.py@:175#L170.

  • awesomeattachmentsplugin/trunk/awesome/awesomeattachments.py

    diff --git a/awesomeattachmentsplugin/trunk/awesome/awesomeattachments.py b/awesomeattachmentsplugin/trunk/awesome/awesomeattachment
    index 88d0cba..7821df2 100644
    a b class AwesomeAttachments(Component): 
    2928    # IRequestFilter methods
    3029
    3130    def pre_process_request(self, req, handler):
    32         if req.path_info.rstrip() == '/newticket' and 'submit' in req.args:
     31        if req.path_info == '/newticket' and 'submit' in req.args:
    3332            req.add_redirect_listener(self._add_attachments)
    3433            req.args.pop('attachment', None)
    3534        return handler
    3635
    3736    def post_process_request(self, req, template, data, content_type):
    38         if template == 'ticket.html' and \
    39                 req.path_info.rstrip() == '/newticket':
     37        if template == 'ticket.html' and req.path_info == '/newticket':
    4038            add_script(req, 'awesome/js/awesome.js')
    4139            add_link(req, 'image',
    4240                     req.href.chrome('awesome/images/add.png'),

comment:36 Changed 8 years ago by Ryan J Ollos

Good points. Feel free to push any improvements, I don't plan to maintain this. I'd like to spend time adding equivalent features to Trac (comment:34), but not sure when I'll have time for that. Basic feature like this plugin, and TracDragDropPlugin as well, are really needed in Trac to keep pace with what users expect these days.

comment:37 Changed 8 years ago by Jun Omae

Committed in [14931] and [14932].

comment:38 Changed 8 years ago by Ryan J Ollos

Oh, typo in [14931]. It should be ticket rather than newticket.

comment:39 Changed 8 years ago by Jun Omae

Thanks. Fixed in [14935] and verified.

comment:40 Changed 8 years ago by Ryan J Ollos

In 14936:

0.4dev: Improve styling with Trac 1.2dev.

Refactored awesome.js and added awesome.css.

Refs #12539.

comment:41 Changed 8 years ago by Ryan J Ollos

In 14937:

0.4dev: Revert unintended change from [14936].

Refs #12539.

comment:42 in reply to:  36 Changed 8 years ago by Ryan J Ollos

Replying to rjollos:

I'd like to spend time adding equivalent features to Trac (comment:34), but not sure when I'll have time for that.

Summary of issues that need to be fixed and areas that would need to be improved if this plugin was added to Trac:

  • Issue: Attachment manipulators are not called.
  • Issue: Data is lost on page reload due to preview, back navigation or validator failure (#7044).
  • Rather than inserting the [[Image]] macro when selecting a file or when the edit description button is pressed, dragging an attachment link to an input text area should insert the [[Image]] macro.
  • Styling of add/remove buttons is poor.
  • Functionality is needed not just for the /newticket page, but also when adding attachments through the attach file form.

Of course we might consider an entirely different approach than what was implemented for this plugin.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.