#3332: Finalize the Mimeview API changes for 0.10
----------------------+-----------------------------------------------------
 Reporter:  cboos     |        Owner:  cboos   
     Type:  task      |       Status:  assigned
 Priority:  high      |    Milestone:  0.10    
Component:  general   |      Version:  devel   
 Severity:  blocker   |   Resolution:          
 Keywords:  mimeview  |  
----------------------+-----------------------------------------------------
Changes (by cboos):

  * owner:  jonas => cboos
  * status:  new => assigned
  * version:  0.9.5 => devel

Comment:

 The main idea of the refactoring is introduce the following new classes:
  - `MimeType`, whose main purpose is to simplify the code dealing with
    mimetype strings, by having always a clear separation between the
    mimetype itself and the optional charset information.
  - `MimeContentBase` classes, which abstract access to typed content.
    By default, there's a `MimeContent` class for encapsulating access
    to string content and a `FileMimeContent` class which encapsulates
    access to file content. The `versioncontrol` subsystem brings its own
    `NodeMimeContent`.
  - `Conversion` objects, for specifying a conversion.

 The highlights of the mimeview API are:

  1. The new `IContentConverter` interface
 {{{
 #!python
 class IContentConverter(Interface):
     """An extension point interface for generic content conversion."""

     def get_supported_conversions(mimetype):
         """Check if conversion of `mimetype` is supported by this
 converter.

         Return an iterable of `Conversion` objects for which this is
         the case.
         """

     def convert_content(context, conversion, content):
         """Convert the given `content` using the specified `conversion`.

         The conversion takes place in the given formatting `context`.

         A `context` can provide at least a `req` property.

         Return the converted content as a new `MimeContent` object.
         """
 }}}

  2. The new `Mimeview` methods, for rendering to HTML and for generic
 conversions:

 {{{
     # -- MIME type conversion

     def get_conversions(self, input):
         """Return a list of possible conversions for the `input` MimeType.

         The returned list contains pair of `(conversion, converter)`
 objects,
         ordered from best to worst quality.
         """

     def convert(self, context, selector, mimecontent):
         """Convert the `mimecontent` to another MIME type.

         The conversion to be done is determined by `selector`,
         which can be either directly the desired output MIME type or
         a key identifying the `Conversion` object.

         Returns a new `MimeContent`.
         """

     def render(self, req, mimecontent, annotations=None):
         """Render an XHTML preview of the given `mimecontent`.

         Some `annotations` might be requested as well.
         """

     # -- Utilities

     def preview_to_hdf(self, req, mimecontent, annotations=None):
         """Prepares a rendered preview of the given `mimecontent`."""

     def send_converted(self, req, selector, mimecontent):
         """Helper method for converting `mimecontent` and sending it
 directly.

         `selector` can be either a key or the expected output MIME Type.
         """
 }}}

 There are still some things in flux at this point, but I think
 it's now in a good state to get some early feedback...

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/3332>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets

Reply via email to