[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/dav/ Merged
isarsprint-dav-work changes r28053:28063 into the trunk;
adding functional tests and code changes to make those work.
Martijn Pieters
mj at zopatista.com
Wed Oct 13 07:59:10 EDT 2004
Log message for revision 28064:
Merged isarsprint-dav-work changes r28053:28063 into the trunk; adding functional tests and code changes to make those work.
Changed:
U Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py
A Zope3/trunk/src/zope/app/dav/ftests/test_proppatch.py
UU Zope3/trunk/src/zope/app/dav/opaquenamespaces.py
U Zope3/trunk/src/zope/app/dav/proppatch.py
-=-
Modified: Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py 2004-10-13 11:47:14 UTC (rev 28063)
+++ Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py 2004-10-13 11:59:08 UTC (rev 28064)
@@ -17,12 +17,13 @@
"""
import unittest
from datetime import datetime
-from transaction import get_transaction
+import transaction
from zope.pagetemplate.tests.util import normalize_xml
from zope.app import zapi
from zope.app.dav.ftests.dav import DAVTestCase
from zope.app.dublincore.interfaces import IZopeDublinCore
+from zope.app.dav.opaquenamespaces import IDAVOpaqueNamespaces
from zope.app.traversing.api import traverse
class TestPROPFIND(DAVTestCase):
@@ -37,7 +38,7 @@
pt = traverse(self.getRootFolder(), '/pt')
adapted = IZopeDublinCore(pt)
adapted.title = u'Test Title'
- get_transaction().commit()
+ transaction.commit()
self.verifyPropOK(path='/pt', ns='http://purl.org/dc/1.1',
prop='title', expect='Test Title', basic='mgr:mgrpw')
@@ -46,7 +47,7 @@
pt = traverse(self.getRootFolder(), '/pt')
adapted = IZopeDublinCore(pt)
adapted.created = datetime.utcnow()
- get_transaction().commit()
+ transaction.commit()
expect = str(adapted.created)
self.verifyPropOK(path='/pt', ns='http://purl.org/dc/1.1',
prop='created', expect=expect, basic='mgr:mgrpw')
@@ -56,10 +57,20 @@
pt = traverse(self.getRootFolder(), '/pt')
adapted = IZopeDublinCore(pt)
adapted.subjects = (u'Bla', u'Ble', u'Bli')
- get_transaction().commit()
+ transaction.commit()
expect = ', '.join(adapted.subjects)
self.verifyPropOK(path='/pt', ns='http://purl.org/dc/1.1',
prop='subjects', expect=expect, basic='mgr:mgrpw')
+
+ def test_opaque(self):
+ self.addPage('/pt', u'<span />')
+ pt = traverse(self.getRootFolder(), '/pt')
+ adapted = IDAVOpaqueNamespaces(pt)
+ adapted[u'uri://bar'] = {u'foo': '<foo>spam</foo>'}
+ transaction.commit()
+ expect = 'spam'
+ self.verifyPropOK(path='/pt', ns='uri://bar',
+ prop='foo', expect=expect, basic='mgr:mgrpw')
def verifyPropOK(self, path, ns, prop, expect, basic):
body = """<?xml version="1.0" ?>
Copied: Zope3/trunk/src/zope/app/dav/ftests/test_proppatch.py (from rev 28063, Zope3/branches/isarsprint-dav-work/src/zope/app/dav/ftests/test_proppatch.py)
Property changes on: Zope3/trunk/src/zope/app/dav/ftests/test_proppatch.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/dav/opaquenamespaces.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/opaquenamespaces.py 2004-10-13 11:47:14 UTC (rev 28063)
+++ Zope3/trunk/src/zope/app/dav/opaquenamespaces.py 2004-10-13 11:59:08 UTC (rev 28064)
@@ -11,9 +11,12 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Attribute Annotations implementation
+"""DAV Opaque properties implementation details
-$Id: attribute.py 26632 2004-07-19 14:56:53Z jim $
+Opaque properties are arbitrary propterties set trhough DAV and which have no
+special meaning to the Zope application.
+
+$Id$
"""
__docformat__ = 'restructuredtext'
@@ -41,6 +44,27 @@
actual opaque value, of the form (((attr1, val1), (attr2, val2)), value)
"""
+
+ def renderProperty(ns, nsprefix, prop, propel):
+ """Render the named property to a DOM subtree
+
+ ns and prop are keys defining the property, nsprefix is the namespace
+ prefix used in the DOM for the namespace of the property, and propel
+ is the <prop> element in the target DOM to which the property DOM
+ elements need to be added.
+
+ """
+
+ def setProperty(propel):
+ """Store a DOM property in the opaque storage
+
+ propel is expected to be a DOM element from which the namespace and
+ property name are taken to be stored.
+
+ """
+
+ def removeProperty(ns, prop):
+ """Remove the indicated property altogether"""
class DAVOpaqueNamespacesAdapter(DictMixin, Location):
@@ -100,6 +124,13 @@
props = self.setdefault(ns, OOBTree())
propel = makeDOMStandalone(propel)
props[propel.nodeName] = propel.toxml('utf-8')
+
+ def removeProperty(self, ns, prop):
+ if self.get(ns, {}).get(prop) is None:
+ return
+ del self[ns][prop]
+ if not self[ns]:
+ del self[ns]
def makeDOMStandalone(element):
@@ -160,7 +191,7 @@
return DOMTransformer(element).makeStandalone()
-def _numberGenerator(i = 0):
+def _numberGenerator(i=0):
while True:
yield i
i += 1
Property changes on: Zope3/trunk/src/zope/app/dav/opaquenamespaces.py
___________________________________________________________________
Name: svn:keywords
+ id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/dav/proppatch.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/proppatch.py 2004-10-13 11:47:14 UTC (rev 28063)
+++ Zope3/trunk/src/zope/app/dav/proppatch.py 2004-10-13 11:59:08 UTC (rev 28064)
@@ -17,6 +17,7 @@
from xml.dom import minidom
+import transaction
from zope.app import zapi
from zope.schema import getFieldNamesInOrder
from zope.app.container.interfaces import IReadContainer
@@ -110,7 +111,7 @@
if _propresults.keys() != [200]:
# At least some props failed, abort transaction
- get_transaction().abort()
+ transaction.abort()
# Move 200 succeeded props to the 424 status
if _propresults.has_key(200):
failed = _propresults.setdefault(424, {})
@@ -168,10 +169,7 @@
# opaque DAV properties
if self.oprops is None:
return 200
- if self.oprops.get(ns, {}).get(prop.localName):
- del self.oprops[ns][prop.localName]
- if not list(self.oprops[ns].keys()):
- del self.oprops[ns]
+ self.oprops.removeProperty(ns, prop.localName)
return 200
# XXX: Deal with registered ns interfaces here
More information about the Zope3-Checkins
mailing list