#3068 closed enhancement (fixed)
Extensible Attachments
Reported by: | 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:
- 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;
- 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; - 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 thematch_request()
, and probably also pass the permissions needed to handle this new type of attachment.
Attachments (2)
Change History (17)
comment:2 by , 19 years ago
Milestone: | → 0.11 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
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 , 19 years ago
Attachment: | milestone_attachments_r3304.patch added |
---|
Add the possibility to have attachments for the Milestone
comment:3 by , 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'))
comment:5 by , 18 years ago
Milestone: | 0.10.1 → 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.
comment:7 by , 18 years ago
Keywords: | security added |
---|---|
Priority: | normal → 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).
comment:8 by , 18 years ago
This is good news. I see no problem or step back by the implementation proposed.
comment:10 by , 17 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:11 by , 17 years ago
You're right I closed this ticket a little be too early, there still one piece missing.
comment:13 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
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 , 17 years ago
Component: | general → attachment |
---|
comment:15 by , 17 years ago
Plugin developers should also have a look at ILegacyAttachmentDelegate.