Commit 39771c0e authored by 's avatar

Changed the way xml is structured because IE doesnt appear smart enough

to deal with multiple propstat elements, though the spec seems to say
that they allowed.
parent 386f4a0c
......@@ -85,7 +85,7 @@
"""WebDAV xml request objects."""
__version__='$Revision: 1.2 $'[11:-2]
__version__='$Revision: 1.3 $'[11:-2]
import sys, os, string, regex
from common import absattr, aq_base, urlfix
......@@ -104,12 +104,20 @@ class DAVProps(DAVProperties):
def v_self(self):
return self.__obj__
## file=open('/projects/users/davtest/var/debug.out', 'w')
## def debug(r):
## file.write(str(r))
## file.write('\n')
## file.write(r.get('BODY', 'No body'))
## file.write('\n\n')
## file.flush()
class PropFind:
"""Model a PROPFIND request."""
def __init__(self, request):
# debug(request)
self.request=request
self.depth='infinity'
self.allprop=0
......@@ -146,6 +154,76 @@ class PropFind:
return
def apply(self, obj, url=None, depth=0, result=None, top=1):
if result is None:
result=StringIO()
depth=self.depth
url=urlfix(self.request['URL'], 'PROPFIND')
url=rel_url(url)
result.write('<?xml version="1.0" encoding="utf-8"?>\n' \
'<d:multistatus xmlns:d="DAV:">\n')
iscol=hasattr(obj, '__dav_collection__')
if iscol and url[-1] != '/': url=url+'/'
result.write('<d:response>\n<d:href>%s</d:href>\n' % url)
if hasattr(obj, '__propsets__'):
propsets=obj.propertysheets.values()
obsheets=obj.propertysheets
else:
davprops=DAVProps(obj)
propsets=(davprops,)
obsheets={'DAV:': davprops}
if self.allprop:
stats=[]
for ps in propsets:
if hasattr(aq_base(ps), 'dav__allprop'):
stats.append(ps.dav__allprop())
stats=string.join(stats, '') or '<d:status>200 OK</d:status>\n'
result.write(stats)
elif self.propname:
stats=[]
for ps in propsets:
if hasattr(aq_base(ps), 'dav__propnames'):
stats.append(ps.dav__propnames())
stats=string.join(stats, '') or '<d:status>200 OK</d:status>\n'
result.write(stats)
elif self.propnames:
rdict={}
for name, ns in self.propnames:
ps=obsheets.get(ns, None)
if ps is not None and hasattr(aq_base(ps), 'dav__propstat'):
stat=ps.dav__propstat(name, rdict)
else:
prop='<n:%s xmlns:n="%s"/>' % (name, ns)
code='404 Not Found'
if not rdict.has_key(code):
rdict[code]=[prop]
else: rdict[code].append(prop)
keys=rdict.keys()
keys.sort()
for key in keys:
result.write('<d:propstat>\n' \
' <d:prop>\n' \
)
map(result.write, rdict[key])
result.write(' </d:prop>\n' \
' <d:status>HTTP/1.1 %s</d:status>\n' \
'</d:propstat>\n' % key
)
else: raise 'Bad Request', 'Invalid request'
result.write('</d:response>\n')
if depth in ('1', 'infinity') and iscol:
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))
depth=depth=='infinity' and depth or 0
self.apply(ob, uri, depth, result, top=0)
if dflag: ob._p_deactivate()
if not top: return result
result.write('</d:multistatus>')
return result.getvalue()
def oapply(self, obj, url=None, depth=0, result=None, top=1):
if result is None:
result=StringIO()
depth=self.depth
......
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