Commit 4f5b11dc authored by 's avatar

Fixed xml attr handling for dead properties

parent 1a09f559
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
"""WebDAV xml request objects.""" """WebDAV xml request objects."""
__version__='$Revision: 1.5 $'[11:-2] __version__='$Revision: 1.6 $'[11:-2]
import sys, os, string import sys, os, string
from common import absattr, aq_base, urlfix from common import absattr, aq_base, urlfix
...@@ -164,22 +164,32 @@ class PropPatch: ...@@ -164,22 +164,32 @@ class PropPatch:
e=root.elements('propertyupdate', ns=dav)[0] e=root.elements('propertyupdate', ns=dav)[0]
for ob in e.elements(): for ob in e.elements():
if ob.name()=='set' and ob.namespace()==dav: if ob.name()=='set' and ob.namespace()==dav:
prop=ob.elements('prop', ns=dav)[0] proptag=ob.elements('prop', ns=dav)[0]
for val in prop.elements(): for prop in proptag.elements():
# We have to ensure that all tag attrs (including # We have to ensure that all tag attrs (including
# an xmlns attr for all xml namespaces used by the # an xmlns attr for all xml namespaces used by the
# element and its children) are saved, per rfc2518. # element and its children) are saved, per rfc2518.
attrs={} name, ns=prop.name(), prop.namespace()
val.remap({}) e, attrs=prop.elements(), prop.attrs()
for attr in val.attrs(): if (not e) and (not attrs):
attrs[attr.name()]=attr.value() # simple property
md={'attrs':attrs, 'nsid': val.__nskey__} item=(name, ns, prop.strval(), {})
item=(val.name(), val.namespace(), val.strval(), md) vals.append(item)
vals.append(item) else:
# xml property
attrs={}
prop.remap({ns:'n'})
prop.del_attr('xmlns:n')
for attr in prop.attrs():
attrs[attr.qname()]=attr.value()
md={'__xml_attrs__':attrs}
item=(name, ns, prop.strval(), md)
vals.append(item)
if ob.name()=='remove' and ob.namespace()==dav: if ob.name()=='remove' and ob.namespace()==dav:
prop=ob.elements('prop', ns=dav)[0] proptag=ob.elements('prop', ns=dav)[0]
for val in prop.elements(): for prop in proptag.elements():
item=(val.name(), val.namespace()) item=(prop.name(), prop.namespace())
vals.append(item) vals.append(item)
def apply(self, obj): def apply(self, obj):
...@@ -202,6 +212,7 @@ class PropPatch: ...@@ -202,6 +212,7 @@ class PropPatch:
obj.propertysheets.manage_addPropertySheet('', ns) obj.propertysheets.manage_addPropertySheet('', ns)
propsets=obj.propertysheets.values() propsets=obj.propertysheets.values()
propset=propsets.get(ns) propset=propsets.get(ns)
propdict=propset._propdict()
if propset.hasProperty(name): if propset.hasProperty(name):
try: propset._updateProperty(name, val, meta=md) try: propset._updateProperty(name, val, meta=md)
except: except:
...@@ -238,6 +249,8 @@ class PropPatch: ...@@ -238,6 +249,8 @@ class PropPatch:
'</d:multistatus>' % errmsg) '</d:multistatus>' % errmsg)
result=result.getvalue() result=result.getvalue()
if not errors: return result if not errors: return result
# This is lame, but I cant find a way to keep ZPublisher
# from sticking a traceback into my xml response :(
get_transaction().abort() get_transaction().abort()
result=string.replace(result, '200 OK', '424 Failed Dependency') result=string.replace(result, '200 OK', '424 Failed Dependency')
return result return result
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
"""WebDAV XML parsing tools.""" """WebDAV XML parsing tools."""
__version__='$Revision: 1.2 $'[11:-2] __version__='$Revision: 1.3 $'[11:-2]
import sys, os, string, xmllib import sys, os, string, xmllib
from Acquisition import Implicit from Acquisition import Implicit
...@@ -211,6 +211,13 @@ class Element(Node): ...@@ -211,6 +211,13 @@ class Element(Node):
return attr return attr
return default return default
def del_attr(self, name):
attrs=[]
for attr in self.__attrs__:
if attr.name() != name:
attrs.append(attr)
self.__attrs__=attrs
def remap(self, dict, n=0, top=1): def remap(self, dict, n=0, top=1):
# The remap method effectively rewrites an element and all of its # The remap method effectively rewrites an element and all of its
# children, consolidating namespace declarations into the element # children, consolidating namespace declarations into the element
......
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