[Zope3-dev] IFile refactoring

Fred Drake fdrake at gmail.com
Mon Jan 24 13:57:40 EST 2005


On Mon, 24 Jan 2005 16:52:54 +0100, Roger Ineichen <dev at projekt01.ch> wrote:
> The contents attribute on IFile is a Mime instance.

So far so good.

> I didn't implement the IMime interface in the File

That's fine too.

> class directly. If we whould do so, we have to
> provide the schema part of IMime. (data, mimeType, encoding)
> as properties.

Not clear that this necessarily follows.

> I think the IFile should only provide:
> 
> contents = Mime
> get/setMimeType()
> get/setEncoding()
> open()
> getSize()

This isn't what's on the branch.  The get/set methods (the IReadMime
and IWriteMime interfaces) should go away; there's no need to provide
methods in addition to normal fields.  There's also no need to have
the data field since we have to have the open() method anyway.  We've
generally moved away from accessors in favor of properties.

I'm a little confused about what the IMime fields speciify; more
detailed documentation is required.  Some specific questions:

- Does the mimeType field include only the major/minor portion of the type, or
  should arbitrary type parameters be part of that as well?  If this
is only for the
  major/minor, then there's no place for type parameters.  One example where the
  type parameters are interesting is the content type "text/plain;
format=flowed";
  many others are defined on a type-specific basis.

- The separation of encoding as a field is something to be careful
about.  It's not
  always possible to tell whether the type is textual using only the major/minor
  type.  It's also worth noting that the "charset" parameter isn't
exactly the same
  as the encoding, and encoding may be determined from the content body in some
  cases if there's no charset parameter on the type (think about XML encodings).

I expect that some additional properties would be helpful:  major and
minor would be nice to be able to access directly, and some way to get
a parameter value would be good to have.  Parameters could be exposed
as a mapping object, for instance.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at gmail.com>
Zope Corporation


More information about the Zope3-dev mailing list