[Zope-Checkins] CVS: Zope/lib/python/webdav - Resource.py:1.48.6.2 webdav_magic.py:1.1.2.2

Andreas Jung andreas@zope.com
Mon, 5 Nov 2001 10:07:32 -0500


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

Modified Files:
      Tag: ajung-webdav-debug
	Resource.py webdav_magic.py 
Log Message:
minor fixes


=== Zope/lib/python/webdav/Resource.py 1.48.6.1 => 1.48.6.2 ===
 from zExceptions import Unauthorized
 
-webdav_magic_enabled = 1
+webdav_magic_enabled = 0
 
 class Resource(ExtensionClass.Base, Lockable.LockableItem):
     """The Resource mixin class provides basic WebDAV support for


=== Zope/lib/python/webdav/webdav_magic.py 1.1.2.1 => 1.1.2.2 ===
 
 
-import Zope
 import OFS.Image
-
 import re, cStringIO
 
 suffix_reg = re.compile('(\.[a-zA-Z]*$)')
@@ -97,7 +95,7 @@
 
 def cloneFile(ob,destId,mime_type):
 
-    file = File(destId, title=destId, 
+    file = OFS.Image.File(destId, title=destId, 
                 file=cStringIO.StringIO(),
                 content_type = mime_type
                 )
@@ -106,15 +104,26 @@
 
 
 def webdavCloneObject(ob,destId):
-        
+
+    # determine object suffix
+    mo = suffix_reg.search(ob.getId())
+    if mo:
+        obj_suffix = mo.group(1)
+    else:
+        obj_suffix = None
+
+    # determine suffix of destId
     mo = suffix_reg.search( destId )
     if mo is None: 
-        raise TypeError, 'wrong suffix'
+        raise TypeError, 'no suffix for destId'
 
     suffix = mo.group(1)
 
     if not magic_mapping.has_key(suffix): 
         raise TypeError, 'no mapping found'
+
+    if obj_suffix == suffix:
+        raise TypeError, 'suffixes are identical'
 
     func, mime_type = magic_mapping[suffix]