Edgewall Software

Ticket #3068 (closed enhancement: fixed)

Opened 3 years ago

Last modified 14 months ago

Extensible Attachments

Reported by: Pedro Algarvio, aka, s0undt3ch <ufs@…> Owned by: cboos
Priority: high Milestone: 0.11
Component: attachment Version: 0.9.5
Severity: normal Keywords: tracobject security
Cc: ufs@…

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

milestone_attachments_r3304.patch (6.8 KB) - added by cboos 3 years ago.
Add the possibility to have attachments for the Milestone
attachment-api.diff (9.5 KB) - added by athomas 3 years ago.
Attachment interface API

Change History

  Changed 3 years ago by cboos

3. is the way to go, of course.

  Changed 3 years ago by cboos

  • owner changed from jonas to cboos
  • status changed from new to assigned
  • milestone set to 0.11

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.

Changed 3 years ago by cboos

Add the possibility to have attachments for the Milestone

  Changed 3 years ago by athomas

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'))

Changed 3 years ago by athomas

Attachment interface API

follow-up: ↓ 5   Changed 2 years ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

  • milestone changed from 0.11 to 0.10.1

Why not for release 0.10.1?

in reply to: ↑ 4   Changed 2 years ago by mgood

  • milestone changed from 0.10.1 to 0.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.

  Changed 2 years ago by cboos

  • keywords tracobject added

#2947 was closed as duplicate.

  Changed 2 years ago by cboos

  • keywords security added
  • priority changed from normal to high

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).

  Changed 2 years ago by Pedro Algarvio, aka, s0undt3ch <ufs@…>

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

  Changed 20 months ago by cboos

  • status changed from assigned to closed
  • resolution set to fixed

Implemented in r5570.

  Changed 19 months ago by athomas

  • status changed from closed to reopened
  • resolution fixed deleted

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.

  Changed 19 months ago by cboos

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

  Changed 19 months ago by cboos

First round of enhancements committed as r5580.

  Changed 19 months ago by cboos

  • status changed from reopened to closed
  • resolution set to fixed

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.

  Changed 14 months ago by cboos

  • component changed from general to attachment

  Changed 14 months ago by cboos

Plugin developers should also have a look at ILegacyAttachmentDelegate.

Add/Change #3068 (Extensible Attachments)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.