Edgewall Software
Modify

Opened 19 years ago

Closed 17 years ago

Last modified 17 years ago

#3068 closed enhancement (fixed)

Extensible Attachments

Reported by: Pedro Algarvio, aka, s0undt3ch <ufs@…> Owned by: Christian Boos
Priority: high Milestone: 0.11
Component: attachment Version: 0.9.5
Severity: normal Keywords: tracobject security
Cc: ufs@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

After a talk with alect on #trac he sugested that this ticket was created.

The Problem:

I'm developing a plugin(WikiTemplates) that will need to support attachments, and, by looking at trac's code, the AttachmentModule only supports wiki and ticket attachments, it doesn't support any other type of attachment.

Possible Solutions:

  1. Create a copy of the attachment.py with the necessary changes, ie, deal with attachments under a different handler, and probalably under a diferent table;
  2. Subclass the classes on attachment.py to add a new attachment type. But this raises a problem. Since it's subclassed, in order to use WikiTemplates attachments, the one that trac provides must be disabled in order for them to work.
    And what if another user creates some other plugin that needs attachment support and takes the same road I do? Both plugins can't be used at the same time.
    Which brings us to the ticket summary and the next solution;
  3. Modify attachment.py so that it's extensible. This way, anyone wanting to use attachments on their plugins would have to for example register their type, and trac would create the necessary dir(s) under /path/to/trac/env/attachments, add the new type to the match_request(), and probably also pass the permissions needed to handle this new type of attachment.

Attachments (2)

milestone_attachments_r3304.patch (6.8 KB ) - added by Christian Boos 19 years ago.
Add the possibility to have attachments for the Milestone
attachment-api.diff (9.5 KB ) - added by Alec Thomas 19 years ago.
Attachment interface API

Download all attachments as: .zip

Change History (17)

comment:1 by Christian Boos, 19 years ago

  1. is the way to go, of course.

comment:2 by Christian Boos, 19 years ago

Milestone: 0.11
Owner: changed from Jonas Borgström to Christian Boos
Status: newassigned

I did some work on this. First, some cleanups for the attachment code, in r3303:3304. Then, on top of that, there's attachment:milestone_attachments_r3304.patch, which adds attachments for Milestones.

That's quite useful if you have an original written "specification" to start with, before you break that down into tickets; you can know attach that spec directly to the milestone).

The problem with the implementation, as one can see in the patch, is mainly with the way the permissions are handled. This clearly needs to be pluggable in some way (Alec?).

Another cumbersome thing is the way to define the parent displayed name in _parent_to_hdf. Here, the TracObject.display_name idea would certainly be adequate.

by Christian Boos, 19 years ago

Add the possibility to have attachments for the Milestone

comment:3 by Alec Thomas, 19 years ago

How about this patch? Adds the following interface:

class IAttachmentPointProvider(Interface):
    def get_attachment_points():
        """Provide details on file attachment points provided by this
        component.  Returns an iterable of tuples in the form `(type,
        description, title, (view_perm, write_perm, delete_perm))`.
        `description` and `title` will be used as the formatting string for the
        attachment point identifier."""

Here's the ticket implementation:

    def get_attachment_points(self):
        yield ('ticket', 'Ticket #%s', '#%s',
               ('TICKET_VIEW', 'TICKET_APPEND', 'TICKET_ADMIN'))

by Alec Thomas, 19 years ago

Attachment: attachment-api.diff added

Attachment interface API

comment:4 by Pedro Algarvio, aka, s0undt3ch <ufs@…>, 18 years ago

Milestone: 0.110.10.1

Why not for release 0.10.1?

in reply to:  4 comment:5 by Matthew Good, 18 years ago

Milestone: 0.10.10.11

Replying to Pedro Algarvio, aka, s0undt3ch <ufs@ufsoft.org>:

Why not for release 0.10.1?

Because 0.10.1 will be a bugfix release so it should not contain any API changes.

comment:6 by Christian Boos, 18 years ago

Keywords: tracobject added

#2947 was closed as duplicate.

comment:7 by Christian Boos, 18 years ago

Keywords: security added
Priority: normalhigh

As the permission handling is being refactoring in the security branch (see PermissionPolicy), the permissions for attachments are going to be more flexible, which was the main difficulty related to this ticket (see also googlegroups:trac-dev:e827b2a40111dbf9).

comment:8 by Pedro Algarvio, aka, s0undt3ch <ufs@…>, 18 years ago

This is good news. I see no problem or step back by the implementation proposed.

comment:9 by Christian Boos, 17 years ago

Resolution: fixed
Status: assignedclosed

Implemented in r5570.

comment:10 by Alec Thomas, 17 years ago

Resolution: fixed
Status: closedreopened

r5570 makes it easier to add per-realm attachment permissions to trunk, while this ticket is about generalising attachment permissions, which r5570 does not do.

comment:11 by Christian Boos, 17 years ago

You're right I closed this ticket a little be too early, there still one piece missing.

comment:12 by Christian Boos, 17 years ago

First round of enhancements committed as r5580.

comment:13 by Christian Boos, 17 years ago

Resolution: fixed
Status: reopenedclosed

As we concluded on #trac, this is good enough for now.

Further enhancements would be at the level of the IPermissionRequestor, which should be enhanced so that an advanced admin module for fine grained permission would be able to see to what kind of resource a given action could apply.

comment:14 by Christian Boos, 17 years ago

Component: generalattachment

comment:15 by Christian Boos, 17 years ago

Plugin developers should also have a look at ILegacyAttachmentDelegate.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos 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.