[CMF-checkins] CVS: CMF/CMFCore - DirectoryView.py:1.17.4.1 FSObject.py:1.8.24.2
Shane Hathaway
shane@cvs.zope.org
Fri, 15 Feb 2002 14:06:50 -0500
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv751
Modified Files:
Tag: cmf-pre-1_3-branch
DirectoryView.py FSObject.py
Log Message:
Read the .properties file next to FS objects to get title, etc. This also
provides a way to specify on a per-file basis that the file extension
should be retained rather than stripped off.
=== CMF/CMFCore/DirectoryView.py 1.17 => 1.17.4.1 ===
return types
+ def _readProperties(self, fp):
+ """Reads the properties file next to an object.
+ """
+ try:
+ f = open(fp, 'rt')
+ except IOError:
+ return None
+ else:
+ lines = f.readlines()
+ f.close()
+ props = {}
+ for line in lines:
+ try: key, value = split(line, '=')
+ except: pass
+ else:
+ props[strip(key)] = strip(value)
+ return props
+
def getContents(self, registry):
changed = 0
if Globals.DevelopmentMode:
@@ -163,8 +181,11 @@
if t is None:
t = registry.getTypeByExtension(ext)
if t is not None:
+ properties = self._readProperties(
+ e_filepath + '.properties')
try:
- ob = t(name, e_filepath, fullname=entry)
+ ob = t(name, e_filepath, fullname=entry,
+ properties=properties)
except:
import traceback
typ, val, tb = exc_info()
=== CMF/CMFCore/FSObject.py 1.8.24.1 => 1.8.24.2 ===
self.__dict__.update(properties)
+ if fullname and properties.get('keep_extension', 0):
+ id = fullname
self.id = id
self.__name__ = id # __name__ is used in traceback reporting
self._filepath = filepath