[Zope] CMFCore.DirectoryView

Elena Schulz elena.schulz@gmx.net
Mon, 30 Dec 2002 15:00:23 +0100


Hi,

I try to connect ZPT to my local Filesytem. Previouesly I used localFS and
DTML which worked nicely. But according to an earlier post by Dieter I
learned that I should use DirectoryView from the CMFCore now.

But thats not so easy as I found.
Does the registration have to be done on every serverstart again? (How to
automate it if so?)
How to add new extensions and metatypes?

Up to now I succeeded to register an arbitrary Directory on my local FS and
different MetaTypes with the external Method given below. But a
corresponding klass has to be given for the registration. How to do that
using classes like the 'FSObject' return bad file error when I try to view
the object in ZMI.

Does anybody know about that? (Or how to use local FS under ZPT?)

-- many thanks for your replies, Elena


the code:

from Products.CMFCore import FSObject
from Products.CMFCore import DirectoryView
DV=DirectoryView

def registerLocalDir (my_dir='my_absolute_FS_path', prefix="",
extList=['css', 'js'], metaList=['Style Sheet'], subdirs=0):

 DV.registerDirectory(my_dir, prefix, subdirs)
 klass=FSObject
 for ext in extList:
  DV.registerFileExtension(ext, klass)
 for mt in metaList:
  DV.registerMetaType(mt, klass)
 return