Forum OpenACS Development: Response to new attachments package

Collapse
Posted by Jun Yamog on
Hi,

Dave is correct that we should move the HTML stuff away from the code.

As for the general attachment packages.  My comment is to have it as a developer friendly service package.  Here is how it may go.

Develop a service based package that is a singleton.  Create tcl API for it to retrieve data, 1 page for posting form data and index.vuh to get the content out.

Lets take the ticket tracker example.  For example on the ticket page you would like to attach files to the ticket.  Here are the steps that will involve the the generel attachment package.

Attach a file.

1. Developer makes a multipart form that will post the the general-attachemnts file-upload.tcl passing the file input type and the object_id of the parent item.  In this case the object_id of the ticket.  The developer may also make this own file-upload.tcl if he/she wishes more cutomization.

2. file-upload.tcl takes in the the file, creates the new cr_items if its a new file, creates a new revision, relates the cr_items.parent_id to the passed object_id.

Attachment Download

1. Ticket page calls general-attachment::get_attachments tcl API passing the object_id of the ticket.  This returns a list of revision_ids.

2. Ticket page creates hrefs to /general-attachment/download/[file name]?revision_id=[revision_id].

Delete Attachments.

1. Ticket page makes hrefs to /general-attachment/file-delete?item_id=[item_id].

2. file-delete deletes the item_id passed to it.

All of the above just make use of the CR api but it makes is very easy for developers to make attachment capability to any packages.

What do you guys think?  The ticket tracker list attach file functions similar to this way.  But Arjun is correct to make a generic general attachment package that way we have a single API to use.