Edgewall Software
Modify

Opened 9 years ago

Last modified 4 hours ago

#2259 assigned defect

No notification email when adding an attachment to a ticket

Reported by: webkontakt@… Owned by: rjollos
Priority: high Milestone: 1.0.3
Component: attachment Version: devel
Severity: major Keywords: notification
Cc: webkontakt@…, kazarmy@…, trac@…, mjlucas@…, stepan@…, tracedgewall@…, fredck@…, shepting@…, itamarost@…, felix.schwarz@…, greg@…, haggai.eran@…, thijstriemstra, ezyang@…, shoffmann, keshav.kini@…, gasolwu@…, leho@…
Release Notes:

Notification email is sent when a ticket attachment is added or deleted and [notification] ticket_notify_attachment = True, which is the default value of the option.

API Changes:

Description

If you just add an attachment to a ticket and change nothing else, no notification emails are sent, even if the CC-Field is filled.

Btw., it's very hard to change anything else (e.g. adding a comment) when adding an attachment, so noone does. Therefore notification is necessary there.

Attachments (8)

trac_ticket_r2659.patch (1.2 KB) - added by trac@… 9 years ago.
patch for notification only. against r2659
trac_ticket_r2659.2.patch (1.1 KB) - added by trac@… 9 years ago.
This patch actually has contents in the email. Sorry about that…
trac_ticket_r2659.3.patch (2.6 KB) - added by trac@… 9 years ago.
full functionality requested. adds remark on timeline
trac_ticket_r6106.patch (1.4 KB) - added by sid 7 years ago.
Update previous submissions to be in line with changes in trunk
attachment_0.13dev.patch (15.2 KB) - added by eblot 4 years ago.
New patch proposal for current trunk (0.13dev)
attachment_0.13dev.2.patch (15.0 KB) - added by eblot 4 years ago.
Fix up some issues with the previous patch, all unit/functional tests now pass Ok.
add-attachment-description.diff (1.9 KB) - added by cboos 4 years ago.
Also send attachment's description in the body of the notificatio n mail. Applies on top of attachment_0.13dev.2.patch.
attachment_1.0.1dev.patch (15.9 KB) - added by eblot 2 years ago.
New patch for latest development version (1.0.1dev), including cboos fixes.

Download all attachments as: .zip

Change History (69)

comment:1 Changed 9 years ago by anonymous

  • Cc webkontakt@… added

comment:2 Changed 9 years ago by Markus Tacker <m@…>

It should also appear on the timeline.

comment:3 Changed 9 years ago by anonymous

  • Cc webkontakt@… added; webkontakt@… removed
  • Version changed from 0.8.4 to 0.9b2

comment:4 Changed 9 years ago by cboos

Related to #1498.

comment:5 Changed 9 years ago by anonymous

  • Version changed from 0.9b2 to 0.9

Changed 9 years ago by trac@…

patch for notification only. against r2659

comment:6 Changed 9 years ago by trac@…

  • Cc webkontakt@… kazarmy@… trac@… added; webkontakt@… removed
  • Version changed from 0.9 to devel

Added attachment for a patch against r2659 that takes care of only the email notification portion of this ticket. Currently does nothing for adding the attachment detail to the timeline.

Changed 9 years ago by trac@…

This patch actually has contents in the email. Sorry about that…

Changed 9 years ago by trac@…

full functionality requested. adds remark on timeline

comment:7 Changed 9 years ago by trac@…

  • Resolution set to fixed
  • Status changed from new to closed

The new patch contains both the email notification for attachments and will add the line "attachment changed" to the timeline when the ticket_show_details configuration option is set (see TracIni).

comment:8 Changed 9 years ago by mgood

  • Resolution fixed deleted
  • Status changed from closed to reopened

Please don't mark a ticket as fixed unless the patch has been committed.

comment:9 Changed 9 years ago by cboos

  • Milestone set to 1.0
  • Owner changed from jonas to cboos
  • Status changed from reopened to new

I have now a few days off the net and, among other things, I'll test the patch (the timeline part, Emmanuel, can you take care of the evaluating the notification part?)

comment:10 Changed 9 years ago by eblot

Sure, I'll do that by the end of this week

comment:11 Changed 9 years ago by eblot

  • Keywords notification email added

comment:12 Changed 9 years ago by eblot

#2897 has been marked as a (partial) duplicate of this ticket.

comment:13 Changed 9 years ago by anonymous

  • Cc mjlucas@… added

comment:14 Changed 9 years ago by mjlucas@…

What is the status of the defect? I have applied the patch.3 to my version of 0.9.3 for testing. The notification section (attachment.py) works as specified and seems to send the correct information to the user (Will be doing testing over the next few days)

However the modifications to web_ui.py seem to cause all sorts of problems. I don't know if it is because of changes landed after this patch was written or what but the timeline gets screwed up with tickets appearing as done on 1/1/1970 (ie. no timestamp) and the firelds appear to be out of place. I haven't looked at what exactly is returned by the SQL statement however if there is a newer patch could someone please post it online.

comment:15 Changed 8 years ago by cboos

  • Milestone changed from 1.0 to 0.11

This ticket will require some general changes on the way the attachment changes interfere with the main resource changes.

See also #1278, which is about a related issue, but for wiki pages.

comment:16 Changed 8 years ago by athomas

r3400 adds attachment timeline events for Wiki pages and tickets.

comment:17 Changed 8 years ago by sid

#2725 is similar (Ticket changetime is not updated with an attachment) and has a patch.

comment:18 Changed 8 years ago by Stefan Reinauer <stepan@…>

  • Cc stepan@… added
  • Keywords attachment added
  • Severity changed from minor to blocker

Hm, bug juggling. I came from #4075 because trac is not attaching ticket attachments to email notifications. This is a critical issue and people are urging me to drop trac for LinuxBIOS again (www.linuxbios.org) because of this.

Unfortunately above patches are a year old and don't apply to our version of trac (0.10) nor do they work if applied manually (server error).

This bug has been there since 0.8.4. Will it ever be fixed?

comment:19 Changed 8 years ago by eblot

  • Severity changed from blocker to major

Come on, be serious, this bug does not prevent from using Trac.

If you want it to be fixed quicker, patches are welcome. As you can see, it is scheduled for 0.11.

comment:20 Changed 8 years ago by stepan@…

I am pretty serious about this one. The common sense seems to be "we dont use browsers because email clients are more concise". While shaking your head might be an appropriate reaction, I still want to keep using trac for this project.

If I manage to come up with a viable solution, I will of course drop a patch to this ticket.

Anyways, thanks for the quick life sign ;-)

comment:21 Changed 8 years ago by eblot

  • Keywords email removed

See also #4281.

comment:22 Changed 8 years ago by cboos

  • Milestone changed from 0.11 to 0.12

comment:23 Changed 8 years ago by anonymous

Is the internal structure of Trac so inflexible that this can not be implemented easily? Someone complained in 0.10 and got put off until 0.11. Now it's 0.12. Why not set it to 2.0 now.

comment:24 Changed 8 years ago by cboos

Ever wondered how Trac manages to go forward? Look at the timeline.

If it's 0.12, it's for a good reason, or rather 3:

  • nobody provided a patch that could accelerate the process to get this feature in
  • there is a bunch of other notification related changes that will hopefully happen in 0.12, so it's natural to group it there
  • there's already too many things scheduled for 0.11 and most likely 2/3 of the still opened 181 tickets (as of this writing) for 0.11 will go to 0.12, if not later.

comment:25 Changed 7 years ago by cboos

  • Cc tracedgewall@… added

#5721 was closed as duplicate. I've added its reporter to the CC: list.

Changed 7 years ago by sid

Update previous submissions to be in line with changes in trunk

comment:26 Changed 7 years ago by sid

I attached an untested patch that does the same thing as the previous patch (minus the timeline work). It should conform to the changes that have happened in trunk since. Any feedback from people willing to test this would be appreciated (and greatly help its chances of getting merged to trunk sooner).

comment:27 Changed 7 years ago by anton

It would be nice if this would work in the 0.11 version.

I set up a trac to communicate with some developers of another company for a project.

I set up mail notification too.

Actually this issue is a problem, because this trac is only for one project between our companies.

Since in both companies the peoples are working on more than one project, its better to be notified by mail than to log in every day (perhaps in other issue / bug systems for different projects) to look in the timeline what did change (even if nothing changed).

comment:28 Changed 7 years ago by cboos

  • Milestone changed from 0.12 to 0.11

sid, thanks for the patch, I did notice it but apparently forgot to test it.

I'll take care of adding that in time for 0.11, after the context-refact merge.

comment:29 Changed 7 years ago by cboos

  • Component changed from ticket system to attachment
  • Keywords attachment removed
  • Milestone changed from 0.11 to 0.12
  • Priority changed from normal to high

Sorry, changed my mind. This has to be redone in a more generic way in 0.12, as it's somewhat a bit unclean to hard-code ticket notifications that way, now that the attachment module is really fully generic.

For those desperately in the need for the feature in the meantime, there's the patch…

comment:30 Changed 7 years ago by niels.reedijk@…

Is this supposed to work? The patch does not apply cleanly to the current trunk, and if I manually merge it, all modules importing Attachment fail. Could I be doing something wrong, or is it the patch?

comment:31 Changed 6 years ago by fredck@…

  • Cc fredck@… added

comment:32 Changed 6 years ago by anonymous

  • Milestone changed from 0.13 to 0.12

comment:33 Changed 6 years ago by shepting@…

  • Cc shepting@… added

Has anyone been able to provide a working patch for 0.11 yet? My company would be interested in using this in a production setting, but just as niels.reedijk noted there are unrecoverable errors when applying this patch.

comment:34 Changed 6 years ago by cboos

There's some discussion on trac-dev about a possible re-implementation of notifications (googlegroups:trac-dev:251bb1e6129dd095). In the meantime you might try the TracHacks:AnnouncerPlugin.

OTOH, adapting the patch to work with 0.11 or trunk shouldn't be hard, I'll give it a try later today.

comment:35 Changed 5 years ago by rblank

  • Milestone changed from 0.12 to next-major-0.1X

It seems that the notification revamp will not happen in 0.12.

comment:36 Changed 5 years ago by peshing@…

hello,

is there, a working patch for trac 0.11. I tryed to make it wotk but I cannot import the Ticket model in attachment.py and that is why the patch is not working…, but I am new to python aniway so please help

comment:37 Changed 5 years ago by itamaro

  • Cc itamarost@… added

comment:38 Changed 4 years ago by fschwarz

  • Cc felix.schwarz@… added

comment:39 Changed 4 years ago by greg@…

  • Cc greg@… added

comment:40 Changed 4 years ago by haggai.eran@…

  • Cc haggai.eran@… added

comment:41 Changed 4 years ago by quintin@…

How's about someone just takes one of the patches and apply it to trunk? Many people are waiting for this change to happen.

Make the timeline integration a second ticket? It's a small job to apply one of the patches to trunk. Those who know how to do it themselves do so, but many people just download and use as-is.

comment:42 Changed 4 years ago by thijstriemstra

  • Cc thijstriemstra added

comment:43 Changed 4 years ago by ezyang@…

  • Cc ezyang@… added

Changed 4 years ago by eblot

New patch proposal for current trunk (0.13dev)

comment:44 Changed 4 years ago by shoffmann

  • Cc shoffmann added

Changed 4 years ago by eblot

Fix up some issues with the previous patch, all unit/functional tests now pass Ok.

comment:45 Changed 4 years ago by cboos

Just tested it and it works fine.

Nit-picking, currently the comment in the mail is simply:

Add attachment "<filename>"

I'd prefer something like:

Attachment "<filename>" added.

(the attachment description)

Changed 4 years ago by cboos

Also send attachment's description in the body of the notificatio n mail. Applies on top of attachment_0.13dev.2.patch.

comment:46 Changed 3 years ago by keshav.kini@…

  • Cc keshav.kini@… added

comment:47 Changed 2 years ago by Ryan J Ollos <ryan.j.ollos@…>

  • Cc ryan.j.ollos@… added

Changed 2 years ago by eblot

New patch for latest development version (1.0.1dev), including cboos fixes.

comment:48 Changed 23 months ago by Gasol Wu <gasolwu@…>

  • Cc gasolwu@… added

comment:49 follow-up: Changed 23 months ago by Gasol Wu <gasolwu@…>

I have written small plugin called AttachmentNotifyPlugin, based on patches of this thread. For someone waiting for 7 years.

comment:50 Changed 5 months ago by rjollos

  • Cc ryan.j.ollos@… removed
  • Milestone changed from next-major-releases to 1.0.3
  • Owner changed from cboos to rjollos
  • Status changed from new to assigned

Tentatively scheduling for 1.0.3, or possibly 1.1.3.

comment:51 Changed 3 months ago by lkraav <leho@…>

  • Cc leho@… added

comment:52 follow-up: Changed 2 weeks ago by rjollos

attachment:attachment_1.0.1dev.patch was rebased on 1.0-stable in log:rjollos.git:t2259-notification-email-when-adding-attachment-to-ticket. The attachment notification is functioning correctly in the limited amount of testing that I've done. I plan to further review the patch.

Shouldn't these class attributes be instance attributes instead?: tags/trac-1.0.1/trac/ticket/notification.py@:136-138#L132. They are modified within an instance method: tags/trac-1.0.1/trac/ticket/notification.py@:162-164#L132.

comment:53 in reply to: ↑ 52 Changed 2 days ago by rjollos

Replying to rjollos:

Shouldn't these class attributes be instance attributes instead?: tags/trac-1.0.1/trac/ticket/notification.py@:136-138#L132. They are modified within an instance method: tags/trac-1.0.1/trac/ticket/notification.py@:162-164#L132.

Change committed to 1.0-stable in [13372] and merged to trunk in [13373].

comment:54 Changed 35 hours ago by rjollos

  • Release Notes modified (diff)

Refactoring in [13374,13376], merged to trunk in [13375,13377].

Last edited 31 hours ago by rjollos (previous) (diff)

comment:55 follow-up: Changed 20 hours ago by rjollos

Some refinements:

  • Wrapped length of attachment added / attachment deleted and attachment description texts.
  • Translation deactivation only encloses necessary code.
  • Added try/except around notify_attachment.
  • notify method is mostly unmodified.

Proposed changes in log:rjollos.git:t2259-notification-email-when-adding-attachment-to-ticket.1.

comment:56 Changed 20 hours ago by rjollos

  • Release Notes modified (diff)

comment:57 in reply to: ↑ 49 Changed 20 hours ago by rjollos

Replying to Gasol Wu <gasolwu@…>:

I have written small plugin called AttachmentNotifyPlugin, based on patches of this thread. For someone waiting for 7 years.

Thank you for providing an interim solution. I've added a note to the th:AttachmentNotifyPlugin to indicate that it won't be needed for Trac ≥ 1.0.3.

comment:58 in reply to: ↑ 55 ; follow-ups: Changed 18 hours ago by jomae

Proposed changes in log:rjollos.git:t2259-notification-email-when-adding-attachment-to-ticket.1.

Quick testing, seems like good. But I think _translation_deactivated is wrong when an exception is raised while executing yield. In the case, the statements after yield wouldn't be executed.

from __future__ import with_statement
from contextlib import contextmanager

@contextmanager
def fn():
    print 'pre'
    yield
    print 'post'

def raising():
    raise ValueError

def main():
    print 'start'
    try:
        with fn():
            raising()
    except ValueError:
        print 'caught'
    print 'end'

main()
$ python2.5 /tmp/test.py
start
pre
caught
end

comment:59 in reply to: ↑ 58 Changed 11 hours ago by rjollos

Replying to jomae:

Proposed changes in log:rjollos.git:t2259-notification-email-when-adding-attachment-to-ticket.1.

Quick testing, seems like good. But I think _translation_deactivated is wrong when an exception is raised while executing yield. In the case, the statements after yield wouldn't be executed.

Thanks, I'll modify the context manager:

from __future__ import with_statement
from contextlib import contextmanager

@contextmanager
def fn():
    print 'pre'
    try:
        yield
    finally:
        print 'post'

def raising():
    raise ValueError

def main():
    print 'start'
    try:
        with fn():
            raising()
    except ValueError:
        print 'caught'
    print 'end'

main()
start
pre
post
caught
end

comment:60 in reply to: ↑ 58 Changed 6 hours ago by rjollos

Replying to jomae:

Quick testing, seems like good. But I think _translation_deactivated is wrong when an exception is raised while executing yield. In the case, the statements after yield wouldn't be executed.

I modified the context manager to handle that scenario in [8ebece33/rjollos.git].

Additional refactoring in [13378], merged in [13379].

comment:61 Changed 4 hours ago by jomae

Unit tests failing with Python 2.7 and TRAC_TEST_DB_URI=sqlite:test.db. All tests pass with Python 2.5 and 2.6.

self.env.reset_db() in tearDown() raises an OperationalError.

...
======================================================================
ERROR: test_ticket_notify_attachment_enabled_attachment_removed (trac.ticket.tests.notification.AttachmentNotificationTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/ticket/tests/notification.py", line 1277, in tearDown
    self.env.reset_db()
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/test.py", line 349, in reset_db
    tables = getattr(m, reset_fn)(self, db_prop)
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/test.py", line 184, in reset_sqlite_db
    db("DELETE FROM %s" % table)
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/db/util.py", line 128, in execute
    cursor.execute(query, params if params is not None else [])
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/db/util.py", line 63, in execute
    r = self.cursor.execute(sql)
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/db/sqlite_backend.py", line 80, in execute
    result = PyFormatCursor.execute(self, *args)
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/db/sqlite_backend.py", line 58, in execute
    args or [])
  File "/run/shm/8ebece33dd566ca3295031f03831ee730e815b31/py27-sqlite-file/trac/db/sqlite_backend.py", line 50, in _rollback_on_error
    return function(self, *args, **kwargs)
OperationalError: disk I/O error

----------------------------------------------------------------------
Ran 1633 tests in 36.747s

FAILED (errors=4)
make: *** [unit-test] Error 1

I think we should call rmtree after reset_db because rmtree removes the SQLite database file.

  • trac/ticket/tests/notification.py

    diff --git a/trac/ticket/tests/notification.py b/trac/ticket/tests/notification.py
    index 9476cba..e101214 100644
    a b class AttachmentNotificationTestCase(unittest.TestCase): 
    12731273    def tearDown(self):
    12741274        """Signal the notification test suite that a test is over"""
    12751275        notifysuite.tear_down()
    1276         shutil.rmtree(self.env.path)
    12771276        self.env.reset_db()
     1277        shutil.rmtree(self.env.path)
    12781278
    12791279    def test_ticket_notify_attachment_enabled_attachment_added(self):
    12801280        self.attachment.insert('foo.txt', StringIO(''), 1)
Last edited 4 hours ago by jomae (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as assigned The owner will remain rjollos.
The ticket will be disowned. Next status will be 'new'.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from rjollos 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.