[Zope3-checkins]
SVN: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/
Small simplification of import
Martijn Pieters
mj at zopatista.com
Sun Oct 10 12:32:14 EDT 2004
Log message for revision 27921:
Small simplification of import
Changed:
U Zope3/branches/isarsprint-dav-work/src/zope/app/dav/configure.zcml
U Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py
A Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py
A Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespacesadapter.py
U Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py
U Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py
-=-
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/configure.zcml
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/configure.zcml 2004-10-10 16:19:23 UTC (rev 27920)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/configure.zcml 2004-10-10 16:32:14 UTC (rev 27921)
@@ -107,7 +107,23 @@
for="*"
permission="zope.Public"
factory=".adapter.DAVSchemaAdapter" />
-
+
+ <!-- XXX: This interface needs to be split up so we can apply seperate
+ permissions for reading and writing -->
+ <adapter
+ factory=".opaquenamespacesadapter.DAVOpaqueNamespacesAdapter"
+ provides="zope.app.dav.interfaces.IDAVOpaqueNamespaces"
+ for="zope.app.annotation.interfaces.IAnnotatable"
+ trusted="true"
+ />
+
+ <class class=".opaquenamespacesadapter.DAVOpaqueNamespacesAdapter">
+ <require
+ permission="zope.ManageContent"
+ interface=".interfaces.IDAVOpaqueNamespaces"
+ />
+ </class>
+
<dav:provideInterface
for="http://purl.org/dc/1.1"
interface="zope.app.dublincore.interfaces.IZopeDublinCore" />
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py 2004-10-10 16:19:23 UTC (rev 27920)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/interfaces.py 2004-10-10 16:32:14 UTC (rev 27921)
@@ -18,6 +18,7 @@
__docformat__ = 'restructuredtext'
from zope.interface import Interface
+from zope.interface.common.mapping import IMapping
from zope.schema import Text
from zope.app.form.interfaces import IWidget
@@ -203,3 +204,12 @@
class ISequenceDAVWidget(IDAVWidget):
"""A DAV widget for sequences."""
+
+class IDAVOpaqueNamespaces(IMapping):
+ """Opaque storage for non-registered DAV namespace properties.
+
+ Any unknown (no interface registered) DAV properties are stored opaquely
+ keyed on their namespace URI, so we can return them later when requested.
+ Thus this is a mapping of a mapping.
+
+ """
Added: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py 2004-10-10 16:19:23 UTC (rev 27920)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py 2004-10-10 16:32:14 UTC (rev 27921)
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Attribute Annotations implementation
+
+$Id: attribute.py 26632 2004-07-19 14:56:53Z jim $
+"""
+__docformat__ = 'restructuredtext'
+
+from UserDict import DictMixin
+
+from zope.interface import implements
+
+from interfaces import IDAVOpaqueNamespaces
+
+
+class DAVOpaqueNamespaces(DictMixin):
+ """Opaque storage for DAV properties."""
+
+ implements(IDAVOpaqueNamespaces)
+
+ def __init__(self, mapping=None):
+ if mapping is None:
+ mapping = {}
+ self._mapping = mapping
+
+ def _changed(self):
+ self._p_changed = True
+
+ def get(self, key, default=None):
+ self._mapping.get(key, default)
+
+ def __getitem__(self, key):
+ return self._mapping[key]
+
+ def keys(self):
+ return self._mapping.keys()
+
+ def __setitem__(self, key, value):
+ self._mapping[key] = value
+
+ def __delitem__(self, key):
+ del self._mapping[key]
Added: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespacesadapter.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespacesadapter.py 2004-10-10 16:19:23 UTC (rev 27920)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespacesadapter.py 2004-10-10 16:32:14 UTC (rev 27921)
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""DAV Opaque Properties Annotatable Adapter
+
+$Id: annotatableadapter.py 26734 2004-07-23 21:55:49Z pruggera $
+"""
+__docformat__ = 'restructuredtext'
+
+from BTrees.OOBTree import OOBTree
+
+from zope.app.annotation.interfaces import IAnnotations, IAnnotatable
+from zope.app.dav.opaquenamespaces import DAVOpaqueNamespaces
+from zope.app.location import Location
+
+DANkey = "zope.app.dav.DAVOpaqueProperties"
+
+
+class DAVOpaqueNamespacesAdapter(DAVOpaqueNamespaces, Location):
+ """Adapt annotatable objects to DAV opaque property storage."""
+
+ __used_for__ = IAnnotatable
+
+ annotations = None
+
+ def __init__(self, context):
+ annotations = IAnnotations(context)
+ oprops = annotations.get(DANkey)
+ if oprops is None:
+ self.annotations = annotations
+ oprops = OOBTree()
+
+ super(DAVOpaqueNamespacesAdapter, self).__init__(oprops)
+
+ def _changed(self):
+ if self.annotations is not None:
+ self.annotations[DANkey] = self._mapping
+ self.annotations = None
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py 2004-10-10 16:19:23 UTC (rev 27920)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py 2004-10-10 16:32:14 UTC (rev 27921)
@@ -19,7 +19,7 @@
from zope.schema import getFieldNamesInOrder
from zope.app import zapi
from zope.app.container.interfaces import IReadContainer
-from zope.app.dav.interfaces import IDAVWidget
+from zope.app.dav.interfaces import IDAVWidget, IDAVOpaqueNamespaces
from zope.app.form.utility import setUpWidgets
from interfaces import IDAVNamespace
@@ -78,11 +78,15 @@
r_url = response.createTextNode(resource_url)
href.appendChild(r_url)
_avail_props = {}
- # TODO: For now, list the propnames for the all namespaces
- # but later on, we need to list *all* propnames from *all* known
- # namespaces that this object has.
+
+ # List all *registered* DAV interface namespaces and their properties
for ns, iface in zapi.getUtilitiesFor(IDAVNamespace):
_avail_props[ns] = getFieldNamesInOrder(iface)
+
+ # List all opaque DAV namespaces and the properties we know of
+ for ns, oprops in IDAVOpaqueNamespaces(self.context, {}).items():
+ _avail_props[ns] = oprops.keys()
+
propname = xmldoc.getElementsByTagNameNS(self.default_ns, 'propname')
if propname:
self._handlePropname(response, re, _avail_props)
Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py 2004-10-10 16:19:23 UTC (rev 27920)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py 2004-10-10 16:32:14 UTC (rev 27921)
@@ -44,7 +44,7 @@
from zope.app.dav.interfaces import IDAVWidget
from zope.app.dav.widget import TextDAVWidget, SequenceDAVWidget
-from zope.app.dav.tests.unitfixtures import File, Folder, FooZPT
+from unitfixtures import File, Folder, FooZPT
import zope.app.location
More information about the Zope3-Checkins
mailing list