[Zope-dev] How Medusa handles file extensions

Tres Seaver tseaver@digicool.com
Thu, 1 Jun 2000 18:55:57 -0400 (EDT)


On Thu, 1 Jun 2000, Andrew Lahser wrote:

> Tres Seaver wrote:
> > Chimezie Thomas-Ogbuji asked:
> > 
> > > Does any one know how the Medusa FTPServer determines
> > > which Zope Object/Product to instanciate based on the
> > > file extension of a newly created file?  For instance
> > > if I create a .dtml file, a DTMLMethod is created, if
> > > I create a .gif file a Image is created, and any
> > > unrecognized extension is instanciated as a File
> > > object.  I'm trying to capture files with .xml
> > > extensions so they are instanciated as XMLDocuments
> > 
> > $ZOPE_HOME/lib/python/OFS/ObjectManager.py contains
> > a helper class, PUTer, which makes this choice.
> > Unfortunately, it doesn't have a hook to allow
> > installation of additional filetype mappings, so I
> > don't see an easy fix.  Refactoring time, anyone?
> > 
> 
> Are you suggesting that a Product would "register" it's
> mime type when its imported at Startup; then the PUTer
> could check all of the registerd Products for an 
> appropriate type before creating an object?

That would be the easiest, but most rigid, implementation.

> Or are you suggesting that there is an external mapping
> of mime-types to Zope objects that might be maintained 
> by someone with Manger privledges? Or even each user
> might be able to adjust the mime-type to zope object
> mapping to suit their work environment?
> 
> Or what did you have in mind?

I didn't think the options through as carefully as you
have:  I probably had the model used by LocalFS in the
back of my head, which is pretty much your "manager"
option.  The user-specific one is an interesting idea,
too.

-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org