[Zope-Checkins] CVS: Zope/lib/python/webdav - davcmds.py:1.14.32.1
Andreas Jung
andreas@zope.com
Thu, 8 Nov 2001 12:43:24 -0500
Update of /cvs-repository/Zope/lib/python/webdav
In directory cvs.zope.org:/tmp/cvs-serv15949/webdav
Modified Files:
Tag: ajung-webdav-debug
davcmds.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/webdav/davcmds.py 1.14 => 1.14.32.1 ===
from urllib import quote
from AccessControl import getSecurityManager
+from mimetypes import reverse_types_map
def safe_quote(url, mark=r'%', find=string.find):
if find(url, mark) > -1:
@@ -212,7 +213,21 @@
else: raise 'Bad Request', 'Invalid request'
result.write('</d:response>\n')
if depth in ('1', 'infinity') and iscol:
+
+ magic_enabled = obj.getProperty("webdav_magic",0)
+
for ob in obj.objectValues():
+
+ objId = ob.getId()
+
+ # webdavmagic
+ if objId.find('.')==-1 and magic_enabled:
+ ct = ob.getProperty('content_type',None)
+ if ct:
+ if reverse_types_map.has_key(ct):
+ objId = objId + reverse_types_map[ct]
+
+
if hasattr(ob,"meta_type"):
if ob.meta_type=="Broken Because Product is Gone": continue
dflag=hasattr(ob, '_p_changed') and (ob._p_changed == None)
@@ -220,7 +235,7 @@
# Do nothing, a null resource shouldn't show up to DAV
if dflag: ob._p_deactivate()
elif hasattr(ob, '__dav_resource__'):
- uri=os.path.join(url, absattr(ob.id))
+ uri=os.path.join(url, objId)
depth=depth=='infinity' and depth or 0
self.apply(ob, uri, depth, result, top=0)
if dflag: ob._p_deactivate()
@@ -448,7 +463,7 @@
if depth == 'infinity' and iscol:
for ob in obj.objectValues():
if hasattr(obj, '__dav_resource__'):
- uri = os.path.join(url, absattr(ob.id))
+ uri = os.path.join(url, absattr(ob.getId()))
self.apply(ob, creator, depth, token, result,
uri, top=0)
if not top: return token, result
@@ -505,7 +520,7 @@
for ob in obj.objectValues():
if hasattr(ob, '__dav_resource__') and \
WriteLockInterface.isImplementedBy(ob):
- uri = os.path.join(url, absattr(ob.id))
+ uri = os.path.join(url, absattr(ob.getId()))
self.apply(ob, token, uri, result, top=0)
if not top: return result
if result.getvalue():
@@ -558,7 +573,7 @@
for ob in obj.objectValues():
dflag = hasattr(ob,'_p_changed') and (ob._p_changed == None)
if hasattr(ob, '__dav_resource__'):
- uri = os.path.join(url, absattr(ob.id))
+ uri = os.path.join(url, absattr(ob.getId()))
self.apply(ob, token, user, uri, result, top=0)
if dflag: ob._p_deactivate()
if not top: return result