Commit fd552539 authored by 's avatar

Minor fixups

parent 4cce4261
......@@ -85,7 +85,7 @@
"""WebDAV support - null resource objects."""
__version__='$Revision: 1.12 $'[11:-2]
__version__='$Revision: 1.13 $'[11:-2]
import sys, os, string, mimetypes
import Acquisition, OFS.content_types
......@@ -99,7 +99,7 @@ class NullResource(Persistent, Acquisition.Implicit, Resource):
"""Null resources are used to handle HTTP method calls on
objects which do not yet exist in the url namespace."""
__dav_null__=1
__null_resource__=1
__ac_permissions__=(
('View', ('HEAD',)),
......@@ -169,7 +169,7 @@ class NullResource(Persistent, Acquisition.Implicit, Resource):
if hasattr(aq_base(parent), name):
raise 'Method Not Allowed', 'The name %s is in use.' % name
if not hasattr(parent, '__dav_collection__'):
raise 'Forbidden', 'Unable to create collection resource.'
raise 'Forbidden', 'Cannot create collection at this location.'
parent.manage_addFolder(name)
RESPONSE.setStatus(201)
RESPONSE.setBody('')
......
......@@ -85,12 +85,24 @@
"""WebDAV support - resource objects."""
__version__='$Revision: 1.15 $'[11:-2]
__version__='$Revision: 1.16 $'[11:-2]
import sys, os, string, mimetypes, xmlcmds
from common import absattr, aq_base, urlfix, rfc1123_date
import exceptions
class error(exceptions.Exception):
def __init__(self, msg):
self.msg=msg
html='<html>\n<head>\n<title></title>\n</head>\n<body>\n' \
'%s\n</body></html>'
def __str__(self, fmt=html):
return fmt % self.msg
class Resource:
"""The Resource mixin class provides basic WebDAV support for
non-collection objects. It provides default implementations
......@@ -240,7 +252,7 @@ class Resource:
except 'Not Found':
raise 'Conflict', 'Object ancestors must already exist.'
except: raise sys.exc_type, sys.exc_value
if hasattr(parent, '__dav_null__'):
if hasattr(parent, '__null_resource__'):
raise 'Conflict', 'Object ancestors must already exist.'
existing=hasattr(aq_base(parent), name)
if existing and oflag=='F':
......@@ -294,7 +306,7 @@ class Resource:
except 'Not Found':
raise 'Conflict', 'The resource %s must exist.' % path
except: raise sys.exc_type, sys.exc_value
if hasattr(parent, '__dav_null__'):
if hasattr(parent, '__null_resource__'):
raise 'Conflict', 'The resource %s must exist.' % path
existing=hasattr(aq_base(parent), name)
if existing and flag=='F':
......
......@@ -85,7 +85,7 @@
"""WebDAV xml request objects."""
__version__='$Revision: 1.15 $'[11:-2]
__version__='$Revision: 1.16 $'[11:-2]
import sys, os, string
from common import absattr, aq_base, urlfix
......@@ -96,7 +96,9 @@ from cStringIO import StringIO
class DAVProps(DAVProperties):
"""Emulate required DAV properties for objects which do
not themselves support properties."""
not themselves support properties. This is mainly so
that non-PropertyManagers can appear to support DAV
PROPFIND requests."""
def __init__(self, obj):
self.__obj__=obj
def v_self(self):
......
......@@ -83,9 +83,13 @@
#
##############################################################################
"""WebDAV XML parsing tools."""
"""WebDAV XML parsing tools. Note that this module does just
enough for the purposes of DAV - it is not intended as a
general xml toolkit, and will probably eventually go away
in favor of a standard xml package once some issues are
worked out."""
__version__='$Revision: 1.4 $'[11:-2]
__version__='$Revision: 1.5 $'[11:-2]
import sys, os, string, xmllib
from Acquisition import Implicit
......@@ -311,7 +315,6 @@ class Text(Node):
def toxml(self):
return escape(self.__value__)
class CData(Node):
__type__=type_cdata
__name__='#cdata'
......@@ -320,27 +323,19 @@ class CData(Node):
def toxml(self):
return '<![CDATA[%s]]>' % self.__value__
class EntityRef(Node):
__name__='#entityref'
__type__=type_entityref
def __init__(self, val):
self.__value__=val
self.__value__=val
def toxml(self):
return '&%s;' % self.__value__
class Entity(Node):
__name__='#entity'
__type__=type_entity
def __init__(self, name, pubid, sysid, nname):
self.__value__=val
def toxml(self):
return ''
......@@ -349,18 +344,14 @@ class ProcInst(Node):
def __init__(self, name, val):
self.__name__=name
self.__value__=val
def toxml(self):
return '<?%s %s?>' % (self.__name__, self.__value__)
class Comment(Node):
__name__='#comment'
__type__=type_comment
def __init__(self, val):
self.__value__=val
def toxml(self):
return '<!--%s-->' % self.__value__
......@@ -425,26 +416,15 @@ class XmlParser(xmllib.XMLParser):
def escape(data, entities={}):
# snarfed from xml.util...
data = string.replace(data, "&", "&amp;")
data = string.replace(data, "<", "&lt;")
data = string.replace(data, ">", "&gt;")
for chars, entity in entities.items():
data = string.replace(data, chars, entity)
def escape(data, rmap={}, replace=string.replace):
data=replace(data, "&", "&amp;")
data=replace(data, "<", "&lt;")
data=replace(data, ">", "&gt;")
for key, val in rmap.items():
data=replace(data, key, val)
return data
def remap(data):
def remap(data, dict={'DAV:': 'd'}):
root=XmlParser().parse(data)
dict={'DAV:':'d', 'http://www.zope.org/propsets/default':'z'}
root.elements()[0].remap(dict, 0)
return root.toxml()
def remap_test():
file=open('big.xml','r')
data=file.read()
file.close()
data=remap(data)
file=open('new.xml','w')
file.write(data)
file.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment