[Zope-Checkins] CVS: Zope/lib/python/OFS - ObjectManager.py:1.143.2.5

Andreas Jung andreas@zope.com
Thu, 8 Nov 2001 12:43:24 -0500


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv15949/OFS

Modified Files:
      Tag: ajung-webdav-debug
	ObjectManager.py 
Log Message:
added support to fake filenames. Folders with a property 'webdav_magic'
will add a corresponding file extension to objects that don't have a 
file extension but have a known mapping of their content_type property to
a file extension.



=== Zope/lib/python/OFS/ObjectManager.py 1.143.2.4 => 1.143.2.5 ===
 from AccessControl import getSecurityManager
 from zLOG import LOG, ERROR,WARNING
-import sys,string,fnmatch,copy
+import sys,string,fnmatch,copy,re
 import types
 from webdav.LockItem import LockItem 
 
@@ -753,6 +753,17 @@
     def __getitem__(self, key):
         v=self._getOb(key, None)
         if v is not None: return v
+
+        # This a real cool hack to find objects with a faked name
+        # through WebDAV.
+
+        if self.getProperty('webdav_magic',0) in ['on',1]:
+            
+            if key.find('.')>-1:
+                key = re.sub('\..*$','',key)
+                v = self._getOb(key,None)
+                if v is not None: return v
+        
         if hasattr(self, 'REQUEST'):
             request=self.REQUEST
             method=request.get('REQUEST_METHOD', 'GET')