[Zope3-checkins] SVN: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/ Refactor: Opaque DAV properties are not a public API, so move all related

Martijn Pieters mj at zopatista.com
Mon Oct 11 05:16:54 EDT 2004


Log message for revision 27943:
  Refactor: Opaque DAV properties are not a public API, so move all related
  classes and code to it's own file and merge the adapter and implementation
  classes.
  


Changed:
  U   Zope3/branches/isarsprint-dav-work/src/zope/app/dav/configure.zcml
  U   Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py
  D   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-11 09:02:50 UTC (rev 27942)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/configure.zcml	2004-10-11 09:16:54 UTC (rev 27943)
@@ -111,13 +111,13 @@
   <!-- 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"
+      factory=".opaquenamespaces.DAVOpaqueNamespacesAdapter"
+      provides=".opaquenamespaces.IDAVOpaqueNamespaces"
       for="zope.app.annotation.interfaces.IAnnotatable"
       trusted="true"
       />
       
-  <class class=".opaquenamespacesadapter.DAVOpaqueNamespacesAdapter">
+  <class class=".opaquenamespaces.DAVOpaqueNamespacesAdapter">
     <require
         permission="zope.ManageContent"
         interface=".interfaces.IDAVOpaqueNamespaces"

Modified: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py	2004-10-11 09:02:50 UTC (rev 27942)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespaces.py	2004-10-11 09:16:54 UTC (rev 27943)
@@ -20,22 +20,49 @@
 from UserDict import DictMixin
 
 from zope.interface import implements
+from zope.interface.common.mapping import IMapping
+from zope.app.annotation.interfaces import IAnnotations, IAnnotatable
+from zope.app.location import Location
 
-from interfaces import IDAVOpaqueNamespaces
+from BTrees.OOBTree import OOBTree
 
+DANkey = "zope.app.dav.DAVOpaqueProperties"
 
-class DAVOpaqueNamespaces(DictMixin):
-    """Opaque storage for DAV properties."""
+
+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. 
+
+    Property values themselves consist of an attributes structure and the 
+    actual opaque value, of the form (((attr1, val1), (attr2, val2)), value) 
     
+    """
+
+    
+class DAVOpaqueNamespacesAdapter(DictMixin, Location):
+    """Adapt annotatable objects to DAV opaque property storage."""
+    
     implements(IDAVOpaqueNamespaces)
+    __used_for__ = IAnnotatable
 
-    def __init__(self, mapping=None):
-        if mapping is None:
-            mapping = {}
-        self._mapping = mapping
+    annotations = None
+
+    def __init__(self, context):
+        annotations = IAnnotations(context)
+        oprops = annotations.get(DANkey)
+        if oprops is None:
+            self.annotations = annotations
+            oprops = OOBTree()
+
+        self._mapping = oprops
         
     def _changed(self):
-        self._p_changed = True
+        if self.annotations is not None:
+            self.annotations[DANkey] = self._mapping
+            self.annotations = None
 
     def get(self, key, default=None):
         return self._mapping.get(key, default)

Deleted: Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespacesadapter.py
===================================================================
--- Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespacesadapter.py	2004-10-11 09:02:50 UTC (rev 27942)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/opaquenamespacesadapter.py	2004-10-11 09:16:54 UTC (rev 27943)
@@ -1,48 +0,0 @@
-##############################################################################
-#
-# 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-11 09:02:50 UTC (rev 27942)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/propfind.py	2004-10-11 09:16:54 UTC (rev 27943)
@@ -19,12 +19,11 @@
 from zope.schema import getFieldNamesInOrder
 from zope.app import zapi
 from zope.app.container.interfaces import IReadContainer
-from zope.app.dav.interfaces import IDAVWidget, IDAVOpaqueNamespaces
 from zope.app.form.utility import setUpWidgets
 
-from interfaces import IDAVNamespace
+from interfaces import IDAVWidget, IDAVNamespace
+from opaquenamespaces import IDAVOpaqueNamespaces
 
-
 class PROPFIND(object):
     """PROPFIND handler for all objects"""
 

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-11 09:02:50 UTC (rev 27942)
+++ Zope3/branches/isarsprint-dav-work/src/zope/app/dav/tests/test_propfind.py	2004-10-11 09:16:54 UTC (rev 27943)
@@ -42,9 +42,9 @@
 from zope.app.dav.interfaces import IDAVSchema
 from zope.app.dav.interfaces import IDAVNamespace
 from zope.app.dav.interfaces import IDAVWidget
-from zope.app.dav.interfaces import IDAVOpaqueNamespaces
 from zope.app.dav.widget import TextDAVWidget, SequenceDAVWidget
-from zope.app.dav.opaquenamespacesadapter import DAVOpaqueNamespacesAdapter
+from zope.app.dav.opaquenamespaces import DAVOpaqueNamespacesAdapter
+from zope.app.dav.opaquenamespaces import IDAVOpaqueNamespaces
 
 from unitfixtures import File, Folder, FooZPT
 



More information about the Zope3-Checkins mailing list