[CMF-checkins] CVS: Products/CMFCore - DirectoryView.py:1.50

Jens Vagelpohl jens at dataflake.org
Mon Feb 28 16:47:51 EST 2005

Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv13816

Modified Files:
Log Message:
- Feature addition to DirectoryView and derived classes: It is now
  possible to customize what gets created to represent directories
  inside the directory view.

  Previously, the code had a fixed assumption that all directories
  on the file system must turn into instances of 
  CMFCore.DirectoryView.DirectoryView(Surrogate). It is now possible
  to register a class deriving from DirectoryView and have that be
  instantiated instead.

  Filesystem directories, unfortunately, carry no meta_type information
  or file extensions by which to recognize them using the available
  registration methods exposed by the DirectoryView module. The somewhat
  kludgy workaround involves using a hardcoded special meta_type with
  the name "FOLDER". Your DirectoryView-derived class can thus be
  registered using the registerMetaType function by specifying the
  name "FOLDER" as the meta_type to register for.

=== Products/CMFCore/DirectoryView.py 1.49 => 1.50 ===
--- Products/CMFCore/DirectoryView.py:1.49	Fri Oct 29 14:42:05 2004
+++ Products/CMFCore/DirectoryView.py	Mon Feb 28 16:47:21 2005
@@ -179,10 +179,15 @@
                     info = registry.getDirectoryInfo(entry_minimal_fp)
                 if info is not None:
-                    mt = types.get(entry)
-                    t = None
-                    if mt is not None:
-                        t = registry.getTypeByMetaType(mt)
+                    # Folders on the file system have no extension or 
+                    # meta_type, as a crutch to enable customizing what gets
+                    # created to represent a filesystem folder in a 
+                    # DirectoryView we use a fake type "FOLDER". That way
+                    # other implementations can register for that type and
+                    # circumvent the hardcoded assumption that all filesystem
+                    # directories will turn into DirectoryViews.
+                    mt = types.get(entry) or 'FOLDER'
+                    t = registry.getTypeByMetaType(mt)
                     if t is None:
                         t = DirectoryView
                     ob = t(entry, entry_minimal_fp)

More information about the CMF-checkins mailing list