[Checkins] SVN: zope.webdav/trunk/src/zope/webdav/ Remove all the etree code from zope.webdav as this is all in zope.etree.

Michael Kerrin michael.kerrin at openapp.biz
Sun Aug 27 06:44:24 EDT 2006


Log message for revision 69791:
  Remove all the etree code from zope.webdav as this is all in zope.etree.
  
  zope.webdav will now require zope.etree to be installed in order to work,
  because it is a new project there is now backwards compatibility for this.
  

Changed:
  U   zope.webdav/trunk/src/zope/webdav/SETUP.cfg
  U   zope.webdav/trunk/src/zope/webdav/datamodel.txt
  U   zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py
  U   zope.webdav/trunk/src/zope/webdav/exceptions/tests/test_multiviews.py
  U   zope.webdav/trunk/src/zope/webdav/ftests/dav.py
  U   zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py
  U   zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py
  D   zope.webdav/trunk/src/zope/webdav/ietree-configure.zcml
  D   zope.webdav/trunk/src/zope/webdav/ietree.py
  U   zope.webdav/trunk/src/zope/webdav/locking.py
  U   zope.webdav/trunk/src/zope/webdav/properties.py
  U   zope.webdav/trunk/src/zope/webdav/propfind.py
  U   zope.webdav/trunk/src/zope/webdav/proppatch.py
  U   zope.webdav/trunk/src/zope/webdav/publisher.py
  D   zope.webdav/trunk/src/zope/webdav/testing.py
  U   zope.webdav/trunk/src/zope/webdav/tests/test_doctests.py
  U   zope.webdav/trunk/src/zope/webdav/tests/test_inputwidgets.py
  U   zope.webdav/trunk/src/zope/webdav/tests/test_locking.py
  U   zope.webdav/trunk/src/zope/webdav/tests/test_propfind.py
  U   zope.webdav/trunk/src/zope/webdav/tests/test_proppatch.py
  U   zope.webdav/trunk/src/zope/webdav/tests/test_publisher.py
  U   zope.webdav/trunk/src/zope/webdav/tests/test_widgets.py
  D   zope.webdav/trunk/src/zope/webdav/tests/test_zetree.py
  U   zope.webdav/trunk/src/zope/webdav/utils.py
  U   zope.webdav/trunk/src/zope/webdav/widgets.py
  D   zope.webdav/trunk/src/zope/webdav/zetree.py

-=-
Modified: zope.webdav/trunk/src/zope/webdav/SETUP.cfg
===================================================================
--- zope.webdav/trunk/src/zope/webdav/SETUP.cfg	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/SETUP.cfg	2006-08-27 10:44:23 UTC (rev 69791)
@@ -3,5 +3,4 @@
 <data-files zopeskel/etc/package-includes>
   zope.webdav-configure.zcml
   zope.webdav-ftesting.zcml
-  ietree-configure.zcml
 </data-files>

Modified: zope.webdav/trunk/src/zope/webdav/datamodel.txt
===================================================================
--- zope.webdav/trunk/src/zope/webdav/datamodel.txt	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/datamodel.txt	2006-08-27 10:44:23 UTC (rev 69791)
@@ -57,8 +57,8 @@
   >>> import zope.webdav.publisher
   >>> import zope.webdav.widgets
   >>> from cStringIO import StringIO
-  >>> import zope.webdav.testing
-  >>> etree = zope.webdav.testing.etreeSetup()
+  >>> from zope.etree.testing import etreeSetup, etreeTearDown, assertXMLEqual
+  >>> etree = etreeSetup()
   >>> component.getGlobalSiteManager().registerAdapter(
   ...    zope.webdav.widgets.IntDAVWidget,
   ...    (zope.schema.interfaces.IInt, zope.webdav.interfaces.IWebDAVRequest),
@@ -149,7 +149,7 @@
 render this type of property.
 
   >>> davwidget = zope.webdav.properties.getWidget(prop, adapter, request)
-  >>> zope.webdav.testing.assertXMLEqual(davwidget.render(),
+  >>> assertXMLEqual(davwidget.render(),
   ...    """<E:age xmlns:E="examplens:">10</E:age>""")
 
 Finally the *zope.webdav.properties.getAllProperties* method contains one entry:
@@ -377,4 +377,4 @@
   True
   >>> component.getGlobalSiteManager().unregisterAdapter(DeadProperties)
   True
-  >>> zope.webdav.testing.etreeTearDown()
+  >>> etreeTearDown()

Modified: zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -30,7 +30,7 @@
 
 import zope.webdav.interfaces
 import zope.webdav.utils
-from zope.webdav.ietree import IEtree
+from zope.etree.interfaces import IEtree
 
 class DAVError(object):
     interface.implements(zope.webdav.interfaces.IDAVErrorWidget)

Modified: zope.webdav/trunk/src/zope/webdav/exceptions/tests/test_multiviews.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/exceptions/tests/test_multiviews.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/exceptions/tests/test_multiviews.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -27,7 +27,7 @@
 from zope.traversing.browser.interfaces import IAbsoluteURL
 
 import zope.webdav.publisher
-from zope.webdav.testing import etreeSetup, etreeTearDown, assertXMLEqual
+from zope.etree.testing import etreeSetup, etreeTearDown, assertXMLEqual
 
 class IResource(interface.Interface):
 

Modified: zope.webdav/trunk/src/zope/webdav/ftests/dav.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/dav.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/ftests/dav.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -40,10 +40,10 @@
 
 import zope.webdav.interfaces
 from zope.webdav.publisher import WebDAVRequest
-from zope.webdav.ietree import IEtree
 from zope.webdav.properties import DAVProperty
-from zope.webdav.testing import assertXMLEqual
 import zope.webdav.coreproperties
+from zope.etree.interfaces import IEtree
+from zope.etree.testing import assertXMLEqual
 
 
 class IExamplePropertyStorage(interface.Interface):

Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -26,7 +26,7 @@
 
 import zope.webdav.interfaces
 from zope.webdav.publisher import WebDAVRequest
-from zope.webdav.testing import assertXMLEqual
+from zope.etree.testing import assertXMLEqual
 
 class PROPPATCHTestCase(dav.DAVTestCase):
 

Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_z3_locking.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -33,10 +33,10 @@
 import zope.locking.utils
 from zope.security.interfaces import Unauthorized
 
-from zope.webdav.testing import assertXMLEqual
 from zope.webdav.interfaces import IDAVLockmanager
 import zope.webdav.publisher
-from zope.webdav.ietree import IEtree
+from zope.etree.interfaces import IEtree
+from zope.etree.testing import assertXMLEqual
 
 class LOCKNotAllowedTestCase(zope.webdav.ftests.dav.DAVTestCase):
 
@@ -46,6 +46,17 @@
         self.assertRaises(MethodNotAllowed, self.publish,
             "/testfilenotallowed", basic = "mgr:mgrpw")
 
+    def test_options(self):
+        file = self.addFile("/testfilenotallowed",
+                            "some file content", "text/plain")
+        response = self.publish("/testfilenotallowed", basic = "mgr:mgrpw",
+                                handle_errors = True)
+
+        allowed = [allow.strip() for allow in
+                   response.getHeader("Allow").split(",")]
+        self.assert_("LOCK" not in allowed)
+        self.assert_("UNLOCK" not in allowed)
+
     def test_lockingprops_noutility(self):
         self.addFile("/testfile", "some file content", "text/plain")
 
@@ -100,6 +111,17 @@
                                       "")
         del self.utility
 
+    def test_options(self):
+        file = self.addFile("/testfilenotallowed",
+                            "some file content", "text/plain")
+        response = self.publish("/testfilenotallowed", basic = "mgr:mgrpw",
+                                handle_errors = True)
+
+        allowed = [allow.strip() for allow in
+                   response.getHeader("Allow").split(",")]
+        self.assert_("LOCK" in allowed)
+        self.assert_("UNLOCK" in allowed)
+
     def test_lock_file_unauthorized(self):
         file = self.addFile("/testfile", "some file content", "text/plain")
 

Deleted: zope.webdav/trunk/src/zope/webdav/ietree-configure.zcml
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ietree-configure.zcml	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/ietree-configure.zcml	2006-08-27 10:44:23 UTC (rev 69791)
@@ -1,35 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
-  <!--
-      ElementTree support for Zope (you probable what to edit this)
-
-      This file also configures which ElementTree engine to use for all the
-      zope.webdav unit tests also. See zope.webdav.testing.
-
-      The following ElementTree engines are supported.
-
-      zope.webdav.zetree.EtreeEtree - original elementtree python module
-
-      zope.webdav.zetree.LxmlEtree - the fast lxml engine.
-
-      zope.webdav.zetree.EtreePy25 - the original elementtree has included in
-                                     python2.5 and above.
-    -->
-
-  <utility
-     factory="zope.webdav.zetree.EtreeEtree"
-     />
-
-<!--
-  <utility
-     factory="zope.webdav.zetree.LxmlEtree"
-     />
--->
-
-<!--
-  <utility
-     factory="zope.webdav.zetree.EtreePy25"
-     />
--->
-
-</configure>

Deleted: zope.webdav/trunk/src/zope/webdav/ietree.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ietree.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/ietree.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -1,94 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""Zope Element Tree Support
-
-XXX - add comments into this interface.
-    - extend this interface to each of the different element tree engines. So
-      some example lxml supports things that the original elementtree
-      implementation did and vice versa. This way developers can say give me
-      an elementtree implementation support feature X. But we still need to be
-      carefull that we still have a common base interface from which to work
-      off.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope import interface
-
-class IEtree(interface.Interface):
-
-    def Comment(text = None):
-        """
-        """
-
-    def dump(elem):
-        """
-        """
-
-    def Element(tag, attrib = {}, **extra):
-        """
-        """
-
-    def ElementTree(element = None, file = None):
-        """
-        """
-
-    def XML(text):
-        """
-        """
-
-    def fromstring(text):
-        """
-        """
-
-    def iselement(element):
-        """
-        """
-
-    def iterparse(source, events = None):
-        """
-        """
-
-    def parse(source, parser = None):
-        """
-        """
-
-    def PI(target, text = None):
-        """
-        """
-
-    def ProcessingInstruction(target, text = None):
-        """
-        """
-
-    def QName(text_or_uri, tag = None):
-        """
-        """
-
-    def SubElement(parent, tag, attrib = {}, **extra):
-        """
-        """
-
-    def tostring(element, encoding = None):
-        """
-        """
-
-    def TreeBuilder(element_factory = None):
-        """
-        """
-
-    def XMLTreeBuilder(html = 0, target = None):
-        """
-        """

Modified: zope.webdav/trunk/src/zope/webdav/locking.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/locking.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/locking.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -47,7 +47,7 @@
 import zope.webdav.interfaces
 import zope.webdav.properties
 from zope.webdav.coreproperties import IActiveLock
-from zope.webdav.ietree import IEtree
+from zope.etree.interfaces import IEtree
 import zope.webdav.utils
 
 MAXTIMEOUT = (2L ** 32) - 1

Modified: zope.webdav/trunk/src/zope/webdav/properties.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/properties.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/properties.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -28,7 +28,7 @@
 from zope.webdav.interfaces import IDAVProperty, IDAVWidget, IDAVInputWidget
 from zope.webdav.interfaces import IOpaquePropertyStorage
 import zope.webdav.widgets
-from zope.webdav.ietree import IEtree
+from zope.etree.interfaces import IEtree
 import zope.webdav.utils
 
 class DAVProperty(object):

Modified: zope.webdav/trunk/src/zope/webdav/propfind.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/propfind.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/propfind.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -42,7 +42,7 @@
 from zope import component
 from zope.app.container.interfaces import IReadContainer
 
-from ietree import IEtree
+from zope.etree.interfaces import IEtree
 import zope.webdav.utils
 import zope.webdav.interfaces
 import zope.webdav.properties

Modified: zope.webdav/trunk/src/zope/webdav/proppatch.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/proppatch.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/proppatch.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -26,7 +26,7 @@
 import zope.webdav.utils
 import zope.webdav.interfaces
 import zope.webdav.properties
-from zope.webdav.ietree import IEtree
+from zope.etree.interfaces import IEtree
 
 
 class PROPPATCH(object):

Modified: zope.webdav/trunk/src/zope/webdav/publisher.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/publisher.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/publisher.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -31,7 +31,7 @@
 from zope.app.publication.http import HTTPPublication
 from zope.app.publication.interfaces import IRequestPublicationFactory
 
-from ietree import IEtree
+from zope.etree.interfaces import IEtree
 import interfaces
 
 

Deleted: zope.webdav/trunk/src/zope/webdav/testing.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/testing.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/testing.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -1,144 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""Zope Element Tree Support
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import zope.component
-import zope.app.component
-from zope.configuration import xmlconfig
-from zope.app.testing import setup
-
-from ietree import IEtree
-import zope.webdav
-
-#
-# Setup for Zope etree. 
-#
-
-def etreeSetup(test = None):
-    setup.placelessSetUp()
-    context = xmlconfig.file("meta.zcml", package = zope.app.component)
-    xmlconfig.file("ietree-configure.zcml", package = zope.webdav,
-                   context = context)
-
-    etreeEtree = zope.component.getUtility(IEtree)
-
-    if test is not None:
-        test.globs["etree"] = etreeEtree
-        test.globs["assertXMLEqual"] = assertXMLEqual
-    return etreeEtree
-
-def etreeTearDown(test = None):
-    if test is not None:
-        del test.globs["etree"]
-        del test.globs["assertXMLEqual"]
-    etreeEtree = zope.component.getUtility(IEtree)
-    zope.component.getGlobalSiteManager().unregisterUtility(etreeEtree)
-
-    setup.placelessTearDown()
-
-#
-# Handy methods for testing if two xml fragmenets are equal.
-#
-
-def _assertTextEqual(got, expected):
-    """
-      >>> _assertTextEqual(None, "\\n")
-      True
-
-      >>> _assertTextEqual("\\n", "\\n")
-      True
-
-      >>> _assertTextEqual("test", "test")
-      True
-
-    """
-    tgot = got and got.strip()
-    texpected = expected and expected.strip()
-
-    error_msg = "'%r != %r' have different element content." %(
-        got, expected)
-
-    if not tgot:
-        assert not texpected, error_msg
-        return True
-
-    if not texpected:
-        assert not tgot, error_msg
-        return True
-
-    assert isinstance(tgot, (str, unicode)), error_msg
-    assert isinstance(texpected, (str, unicode)), error_msg
-
-    assert tgot == texpected, error_msg
-
-    return True
-
-def _assertXMLElementEqual(got, expected):
-    etree = zope.component.getUtility(IEtree)
-
-    assert got.tag == expected.tag, \
-           "'%r != %r' different tag name." %(got.tag, expected.tag)
-    assert len(got) == len(expected), \
-           "'%d != %d' different number of subchildren on %r." %(
-               len(got), len(expected), got.tag)
-    _assertTextEqual(got.text, expected.text)
-
-    for index in range(0, len(got)):
-        _assertXMLElementEqual(got[index], expected[index])
-
-
-def assertXMLEqual(got, expected):
-    """
-      >>> etree = etreeSetup()
-      >>> assertXMLEqual('<test>xml</test>', '<test>xml</test>')
-
-      >>> assertXMLEqual('<test>xml</test>', '<test>xml1</test>')
-      Traceback (most recent call last):
-      ...
-      AssertionError: ''xml' != 'xml1'' have different element content.
-
-      >>> assertXMLEqual('<test><subtest>Test</subtest></test>',
-      ...                '<test>Test</test>')
-      Traceback (most recent call last):
-      ...
-      AssertionError: '1 != 0' different number of subchildren on 'test'.
-
-      >>> assertXMLEqual('<test1/>', '<test2/>')
-      Traceback (most recent call last):
-      ...
-      AssertionError: ''test1' != 'test2'' different tag name.
-
-      >>> assertXMLEqual('<a><b><c /></b></a>', '<a><b><c/></b></a>')
-      >>> etreeTearDown()
-
-    """
-    etree = zope.component.getUtility(IEtree)
-
-    if isinstance(got, (str, unicode)):
-        got = etree.fromstring(got)
-    if isinstance(expected, (str, unicode)):
-        expected = etree.fromstring(expected)
-
-    if getattr(got, "getroot", None) is not None:
-        # XXX - is this all neccessary.
-        got = got.getroot()
-
-        assert getattr(expected, "getroot", None) is not None
-        expected = expected.getroot()
-
-    _assertXMLElementEqual(got, expected)

Modified: zope.webdav/trunk/src/zope/webdav/tests/test_doctests.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_doctests.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_doctests.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -34,7 +34,7 @@
      queryInteraction
 from zope.traversing.browser.interfaces import IAbsoluteURL
 
-from zope.webdav.testing import etreeSetup, etreeTearDown
+from zope.etree.testing import etreeSetup, etreeTearDown
 
 
 class IDemo(IContained):
@@ -193,11 +193,6 @@
                              setUp = contentSetup, tearDown = contentTeardown),
         doctest.DocTestSuite("zope.webdav.utils",
                              setUp = etreeSetup, tearDown = etreeTearDown),
-##         doctest.DocTestSuite("zope.webdav.zetree", optionflags = \
-##                              doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE),
-        doctest.DocTestSuite("zope.webdav.testing",
-                             optionflags = doctest.ELLIPSIS + \
-                                           doctest.NORMALIZE_WHITESPACE),
         doctest.DocTestSuite("zope.webdav.coreproperties"),
         doctest.DocFileSuite("datamodel.txt", package = "zope.webdav"),
         doctest.DocTestSuite("zope.webdav.lockingutils",

Modified: zope.webdav/trunk/src/zope/webdav/tests/test_inputwidgets.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_inputwidgets.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_inputwidgets.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -30,8 +30,8 @@
 
 from zope.webdav import widgets
 from zope.webdav.interfaces import IDAVInputWidget
-from zope.webdav.ietree import IEtree
-from zope.webdav.testing import etreeSetup, etreeTearDown
+from zope.etree.interfaces import IEtree
+from zope.etree.testing import etreeSetup, etreeTearDown
 
 from test_widgets import TestWebDAVRequest
 

Modified: zope.webdav/trunk/src/zope/webdav/tests/test_locking.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_locking.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_locking.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -36,7 +36,7 @@
 from zope.webdav.locking import UNLOCKMethod, LOCKMethod
 import zope.webdav.publisher
 import zope.webdav.interfaces
-from zope.webdav.testing import etreeSetup, etreeTearDown, assertXMLEqual
+from zope.etree.testing import etreeSetup, etreeTearDown, assertXMLEqual
 
 _randGen = random.Random(time.time())
 

Modified: zope.webdav/trunk/src/zope/webdav/tests/test_propfind.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_propfind.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_propfind.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -36,7 +36,8 @@
 import zope.webdav.exceptions
 import zope.webdav.coreproperties
 from zope.webdav.propfind import PROPFIND
-from zope.webdav.testing import etreeSetup, etreeTearDown, assertXMLEqual
+from zope.etree.testing import etreeSetup, etreeTearDown, assertXMLEqual
+from zope.etree.interfaces import IEtree
 
 class TestRequest(zope.webdav.publisher.WebDAVRequest):
 
@@ -371,7 +372,7 @@
         request = zope.webdav.publisher.WebDAVRequest(StringIO(""), {})
         propf = PROPFIND(None, None)
 
-        etree = component.getUtility(zope.webdav.ietree.IEtree)
+        etree = component.getUtility(IEtree)
         props = etree.fromstring("""<prop xmlns="DAV:" xmlns:D="DAVtest:">
 <D:exampletextprop />
 <D:exampleintprop />
@@ -393,7 +394,7 @@
         request = zope.webdav.publisher.WebDAVRequest(StringIO(""), {})
         propf = PROPFIND(None, None)
 
-        etree = component.getUtility(zope.webdav.ietree.IEtree)
+        etree = component.getUtility(IEtree)
         props = etree.fromstring("""<prop xmlns="DAV:" xmlns:D="DAVtest:">
 <D:exampletextprop />
 <D:extratextprop />
@@ -439,7 +440,7 @@
         request = zope.webdav.publisher.WebDAVRequest(StringIO(""), {})
         propf = PROPFIND(None, None)
 
-        etree = component.getUtility(zope.webdav.ietree.IEtree)
+        etree = component.getUtility(IEtree)
         include = etree.fromstring("""<include xmlns="DAV:" xmlns:D="DAVtest:">
 <D:exampletextprop />
 </include>""")
@@ -480,7 +481,7 @@
         propf = PROPFIND(None, None)
 
         exampleTextProperty.restricted = True
-        etree = component.getUtility(zope.webdav.ietree.IEtree)
+        etree = component.getUtility(IEtree)
         include = etree.fromstring("""<include xmlns="DAV:" xmlns:D="DAVtest:">
 <D:exampletextprop />
 </include>""")
@@ -516,7 +517,7 @@
         propf = PROPFIND(collection, request)
 
         result = propf.PROPFIND()
-        etree = component.getUtility(zope.webdav.ietree.IEtree)
+        etree = component.getUtility(IEtree)
         etree.fromstring(result)
 
         assertXMLEqual(result, """<ns0:multistatus xmlns:ns0="DAV:">

Modified: zope.webdav/trunk/src/zope/webdav/tests/test_proppatch.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_proppatch.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_proppatch.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -31,8 +31,8 @@
 import zope.webdav.proppatch
 import zope.webdav.publisher
 import zope.webdav.interfaces
-from zope.webdav.ietree import IEtree
-from zope.webdav.testing import etreeSetup, etreeTearDown, assertXMLEqual
+from zope.etree.interfaces import IEtree
+from zope.etree.testing import etreeSetup, etreeTearDown, assertXMLEqual
 
 class TestRequest(zope.webdav.publisher.WebDAVRequest):
 

Modified: zope.webdav/trunk/src/zope/webdav/tests/test_publisher.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_publisher.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_publisher.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -25,6 +25,9 @@
 from zope.webdav.publisher import WebDAVRequest
 from zope.webdav.interfaces import IWebDAVRequest, IWebDAVResponse, BadRequest
 
+from zope.etree.testing import etreeSetup
+from zope.etree.testing import etreeTearDown
+
 def create_request(body = None, env = {}):
     if isinstance(body, types.StringTypes):
         body = StringIO(body)
@@ -36,11 +39,9 @@
 class TestWebDAVPublisher(unittest.TestCase):
 
     def setUp(self):
-        from zope.webdav.testing import etreeSetup
         self.etree = etreeSetup()
 
     def tearDown(self):
-        from zope.webdav.testing import etreeTearDown
         etreeTearDown()
 
     def test_noinput(self):

Modified: zope.webdav/trunk/src/zope/webdav/tests/test_widgets.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_widgets.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_widgets.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -30,7 +30,7 @@
 from zope.webdav import widgets
 import zope.webdav.interfaces
 from zope.webdav.publisher import WebDAVRequest
-from zope.webdav.testing import etreeSetup, etreeTearDown, assertXMLEqual
+from zope.etree.testing import etreeSetup, etreeTearDown, assertXMLEqual
 
 
 class TestWebDAVRequest(WebDAVRequest):

Deleted: zope.webdav/trunk/src/zope/webdav/tests/test_zetree.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/tests/test_zetree.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/tests/test_zetree.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -1,169 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""Test the ElementTree support within WebDAV. These aren't really tests but
-more of an assertion that I spelt things, like variable names correctly. By
-ust calling the methods here I have managed to find a bunch of bugs :-)
-
-Otherwise I just assume that underlying engine does its job correctly.
-
-$Id$
-"""
-
-import unittest
-from cStringIO import StringIO
-
-from zope.interface.verify import verifyObject
-import zope.webdav.zetree
-from zope.webdav.ietree import IEtree
-
-
-class BaseEtreeTestCase(unittest.TestCase):
-
-    def test_interface(self):
-        self.assertEqual(verifyObject(IEtree, self.etree), True)
-
-    def test_comment(self):
-        comment = self.etree.Comment(u"some text")
-
-    def test_etree(self):
-        etree = self.etree.ElementTree()
-
-    def test_XML(self):
-        xml = self.etree.XML(u"<p>some text</p>")
-
-    def test_fromstring(self):
-        xml = self.etree.fromstring(u"<p>some text</p>")
-
-    def test_element(self):
-        elem = self.etree.Element(u"testtag")
-
-    def test_iselement(self):
-        elem = self.etree.Element(u"testtag")
-        iselem = self.etree.iselement(elem)
-        self.assert_(iselem, "Not an element")
-
-    def test_parse(self):
-        f = StringIO("<b>Test Source String</b>")
-        self.etree.parse(f)
-
-    def test_qname(self):
-        qname = self.etree.QName("http://example.namespace.org", "test")
-
-    def test_tostring(self):
-        elem = self.etree.Element(u"testtag")
-        string = self.etree.tostring(elem, "ascii")
-        self.assert_(isinstance(string, str), "Not a string")
-
-    def test_treeBuilder(self):
-        self.assertRaises(NotImplementedError, self.etree.TreeBuilder)
-
-    def test_subelement(self):
-        elem = self.etree.Element(u"testtag")
-        subel = self.etree.SubElement(elem, "foo")
-
-    def test_PI(self):
-        pi = self.etree.PI("sometarget")
-
-    def test_processinginstructions(self):
-        pi = self.etree.ProcessingInstruction("sometarget")
-
-    def test_xmltreebulider(self):
-        builder = self.etree.XMLTreeBuilder()
-
-
-class OrigElementTreeTestCase(BaseEtreeTestCase):
-
-    def setUp(self):
-        self.etree = zope.webdav.zetree.EtreeEtree()
-
-    def tearDown(self):
-        del self.etree
-
-
-class LXMLElementTreeTestCase(BaseEtreeTestCase):
-
-    def setUp(self):
-        self.etree = zope.webdav.zetree.LxmlEtree()
-
-    def tearDown(self):
-        del self.etree
-
-    def test_PI(self):
-        self.assertRaises(NotImplementedError, self.etree.PI, "sometarget")
-
-    def test_processinginstructions(self):
-        self.assertRaises(NotImplementedError,
-                          self.etree.ProcessingInstruction, "sometarget")
-
-    def test_xmltreebulider(self):
-        self.assertRaises(NotImplementedError, self.etree.XMLTreeBuilder)
-
-    def test_namespaces(self):
-        # When we have a element whoes namespace declaration is declared
-        # in a parent element lxml doesn't print out the namespace
-        # declaration by default.
-        multinselemstr = """<D:prop xmlns:D="DAV:"><D:owner><H:href xmlns:H="examplens">http://example.org</H:href></D:owner></D:prop>"""
-        multinselem = self.etree.fromstring(multinselemstr)
-        self.assertEqual(self.etree.tostring(multinselem[0]),
-                         """<D:owner xmlns:D="DAV:"><H:href xmlns:H="examplens">http://example.org</H:href></D:owner>""")
-
-
-class Python25ElementTreeTestCase(BaseEtreeTestCase):
-
-    def setUp(self):
-        self.etree = zope.webdav.zetree.EtreePy25()
-
-    def tearDown(self):
-        del self.etree
-
-
-class NoElementTreePresentTestCase(unittest.TestCase):
-    # If no element tree engine exists then run this test case. Which will
-    # mark the current instance has broken.
-
-    def test_warn(self):
-        self.fail("""
-        WARNING: zope.webdav needs elementtree installed in order to run.
-        """)
-
-def test_suite():
-    suite = unittest.TestSuite()
-
-    # Only run the tests for each elementtree that is installed.
-    foundetree = False
-    try:
-        import elementtree
-        suite.addTest(unittest.makeSuite(OrigElementTreeTestCase))
-        foundetree = True
-    except ImportError:
-        pass
-
-    try:
-        import lxml.etree
-        suite.addTest(unittest.makeSuite(LXMLElementTreeTestCase))
-        foundetree = True
-    except ImportError:
-        pass
-
-    try:
-        import xml.etree
-        suite.addTest(unittest.makeSuite(Python25ElementTreeTestCase))
-        foundetree = True
-    except ImportError:
-        pass
-
-    if not foundetree:
-        suite.addTest(unittest.makeSuite(NoElementTreePresentTestCase))
-
-    return suite

Modified: zope.webdav/trunk/src/zope/webdav/utils.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/utils.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/utils.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -40,7 +40,7 @@
 from zope.publisher.http import status_reasons
 from zope.traversing.browser.interfaces import IAbsoluteURL
 from zope.app.container.interfaces import IReadContainer
-from ietree import IEtree
+from zope.etree.interfaces import IEtree
 
 class IPropstat(interface.Interface):
     """Helper interface to render a response XML element. 

Modified: zope.webdav/trunk/src/zope/webdav/widgets.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/widgets.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/widgets.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -19,7 +19,7 @@
 from zope import interface
 from zope.schema import getFieldsInOrder
 
-from zope.webdav.ietree import IEtree
+from zope.etree.interfaces import IEtree
 import interfaces
 
 import zope.datetime

Deleted: zope.webdav/trunk/src/zope/webdav/zetree.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/zetree.py	2006-08-27 10:21:54 UTC (rev 69790)
+++ zope.webdav/trunk/src/zope/webdav/zetree.py	2006-08-27 10:44:23 UTC (rev 69791)
@@ -1,305 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 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.
-#
-##############################################################################
-"""Zope Element Tree Support
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import copy
-from zope.interface import implements
-
-from ietree import IEtree
-
-class BaseEtree(object):
-    def Comment(self, text = None):
-        return self.etree.Comment(text)
-
-    # XXX - not tested
-    def dump(self, elem):
-        return self.etree.dump(elem)
-
-    def Element(self, tag, attrib = {}, **extra):
-        return self.etree.Element(tag, attrib, **extra)
-
-    def ElementTree(self, element = None, file = None):
-        return self.etree.ElementTree(element, file)
-
-    def XML(self, text):
-        return self.etree.fromstring(text)
-
-    fromstring = XML
-
-    def iselement(self, element):
-        return self.etree.iselement(element)
-
-    # XXX - not tested
-    def iterparse(self, source, events = None):
-        return self.etree.iterparse(source, events)
-
-    def parse(self, source, parser = None):
-        return self.etree.parse(source, parser)
-
-    def PI(self, target, text = None):
-        raise NotImplementedError, "lxml doesn't implement PI"
-
-    ProcessingInstruction = PI
-
-    def QName(self, text_or_uri, tag = None):
-        return self.etree.QName(text_or_uri, tag)
-
-    def SubElement(self, parent, tag, attrib = {}, **extra):
-        return self.etree.SubElement(parent, tag, attrib, **extra)
-
-    def tostring(self, element, encoding = None):
-        return self.etree.tostring(element, encoding)
-
-    def TreeBuilder(self, element_factory = None):
-        raise NotImplementedError, "lxml doesn't implement TreeBuilder"
-
-    def XMLTreeBuilder(self, html = 0, target = None):
-        raise NotImplementedError, "lxml doesn't implement XMLTreeBuilder"
-
-
-class EtreeEtree(BaseEtree):
-    """
-    Support for ElementTree
-
-      >>> from cStringIO import StringIO
-      >>> from zope.interface.verify import verifyObject
-      >>> letree = EtreeEtree()
-      >>> verifyObject(IEtree, letree)
-      True
-
-      >>> letree.Comment(u'some text') #doctest:+ELLIPSIS
-      <Element <function Comment at ...
-
-      >>> letree.Element(u'testtag')
-      <Element...
-
-      >>> letree.ElementTree() #doctest:+ELLIPSIS
-      <elementtree.ElementTree.ElementTree instance at ...
-
-      >>> letree.XML(u'<p>some text</p>')
-      <Element p ...
-
-      >>> letree.fromstring(u'<p>some text</p>')
-      <Element p ...
-
-      >>> elem = letree.Element(u'testtag')
-      >>> letree.iselement(elem)
-      1
-
-      >>> f = StringIO('<b>Test Source String</b>')
-      >>> letree.parse(f) #doctest:+ELLIPSIS
-      <elementtree.ElementTree.ElementTree instance at ...
-
-      >>> letree.QName('http://example.namespace.org', 'test')#doctest:+ELLIPSIS
-      <elementtree.ElementTree.QName instance at...
-
-      >>> print letree.tostring(elem, 'ascii')
-      <?xml version='1.0' encoding='ascii'?>
-      <testtag />
-
-      >>> letree.TreeBuilder()
-      Traceback (most recent call last):
-      ...
-      NotImplementedError: lxml doesn't implement TreeBuilder
-
-      >>> subel = letree.SubElement(elem, 'foo')
-      >>> letree.tostring(elem)
-      '<testtag><foo /></testtag>'
-
-      >>> letree.PI('sometarget')  #doctest:+ELLIPSIS
-      <Element <function ProcessingInstruction at ...
-
-      >>> letree.ProcessingInstruction('sometarget') #doctest:+ELLIPSIS
-      <Element <function ProcessingInstruction at ...
-
-      >>> letree.XMLTreeBuilder()
-      <elementtree.ElementTree.XMLTreeBuilder instance at ...
-
-    """
-    implements(IEtree)
-
-    def __init__(self):
-        from elementtree import ElementTree
-        self.etree = ElementTree
-
-    def XMLTreeBuilder(self, html = 0, target = None):
-        return self.etree.XMLTreeBuilder(html, target)
-
-    def PI(self, target, text = None):
-        return self.etree.PI(target, text)
-
-    ProcessingInstruction = PI
-
-
-class EtreePy25(BaseEtree):
-    """
-    Support for ElementTree
-
-      >>> from cStringIO import StringIO
-      >>> from zope.interface.verify import verifyObject
-      >>> letree = EtreePy25()
-      >>> verifyObject(IEtree, letree)
-      True
-
-      >>> letree.Comment(u'some text') #doctest:+ELLIPSIS
-      <Element <function Comment at ...
-
-      >>> letree.Element(u'testtag')
-      <Element...
-
-      >>> letree.ElementTree() #doctest:+ELLIPSIS
-      <xml.etree.ElementTree.ElementTree instance at ...
-
-      >>> letree.XML(u'<p>some text</p>')
-      <Element p ...
-
-      >>> letree.fromstring(u'<p>some text</p>')
-      <Element p ...
-
-      >>> elem = letree.Element(u'testtag')
-      >>> letree.iselement(elem)
-      1
-
-      >>> f = StringIO('<b>Test Source String</b>')
-      >>> letree.parse(f) #doctest:+ELLIPSIS
-      <xml.etree.ElementTree.ElementTree instance at ...
-
-      >>> letree.QName('http://example.namespace.org', 'test')#doctest:+ELLIPSIS
-      <xml.etree.ElementTree.QName instance at...
-
-      >>> print letree.tostring(elem, 'ascii')
-      <?xml version='1.0' encoding='ascii'?>
-      <testtag />
-
-      >>> letree.TreeBuilder()
-      Traceback (most recent call last):
-      ...
-      NotImplementedError: lxml doesn't implement TreeBuilder
-
-      >>> subel = letree.SubElement(elem, 'foo')
-      >>> letree.tostring(elem)
-      '<testtag><foo /></testtag>'
-
-      >>> letree.PI('sometarget')  #doctest:+ELLIPSIS
-      <Element <function ProcessingInstruction at ...
-
-      >>> letree.ProcessingInstruction('sometarget') #doctest:+ELLIPSIS
-      <Element <function ProcessingInstruction at ...
-
-      >>> letree.XMLTreeBuilder()
-      <xml.etree.ElementTree.XMLTreeBuilder instance at ...
-
-    """
-    implements(IEtree)
-
-    def __init__(self):
-        from xml.etree import ElementTree
-        self.etree = ElementTree
-
-    def XMLTreeBuilder(self, html = 0, target = None):
-        return self.etree.XMLTreeBuilder(html, target)
-
-    def PI(self, target, text = None):
-        return self.etree.PI(target, text)
-
-    ProcessingInstruction = PI
-
-
-class LxmlEtree(BaseEtree):
-    """
-    Support for lxml.
-
-      >>> from cStringIO import StringIO
-      >>> from zope.interface.verify import verifyObject
-      >>> letree = LxmlEtree()
-      >>> verifyObject(IEtree, letree)
-      True
-
-      >>> letree.Comment(u'some text')
-      <Comment[some text]>
-
-      >>> letree.Element(u'testtag')
-      <Element...
-
-      >>> letree.ElementTree()
-      <etree._ElementTree...
-
-      >>> letree.XML(u'<p>some text</p>')
-      <Element p ...
-
-      >>> letree.fromstring(u'<p>some text</p>')
-      <Element p ...
-
-    When we have a element whoes namespace declaration is declared in a parent
-    element lxml doesn't print out the namespace declaration by default.
-
-      >>> multinselemstr = '<D:prop xmlns:D="DAV:"><D:owner><H:href xmlns:H="examplens">http://example.org</H:href></D:owner></D:prop>'
-      >>> multinselem = letree.fromstring(multinselemstr)
-      >>> letree.tostring(multinselem[0])
-      '<D:owner xmlns:D="DAV:"><H:href xmlns:H="examplens">http://example.org</H:href></D:owner>'
-
-      >>> elem = letree.Element(u'testtag')
-      >>> letree.iselement(elem)
-      1
-
-      >>> f = StringIO('<b>Test Source String</b>')
-      >>> letree.parse(f)
-      <etree._ElementTree object at ...
-
-      >>> letree.QName('http://example.namespace.org', 'test')
-      <etree.QName object at...
-
-      >>> letree.tostring(elem, 'ascii')
-      '<testtag/>'
-
-      >>> letree.TreeBuilder()
-      Traceback (most recent call last):
-      ...
-      NotImplementedError: lxml doesn't implement TreeBuilder
-
-      >>> subel = letree.SubElement(elem, 'foo')
-      >>> subel.getparent() is elem
-      True
-
-      >>> letree.PI('sometarget')
-      Traceback (most recent call last):
-      ...
-      NotImplementedError: lxml doesn't implement PI
-
-      >>> letree.ProcessingInstruction('sometarget')
-      Traceback (most recent call last):
-      ...
-      NotImplementedError: lxml doesn't implement PI
-
-      >>> letree.XMLTreeBuilder()
-      Traceback (most recent call last):
-      ...
-      NotImplementedError: lxml doesn't implement XMLTreeBuilder
-
-    """
-    implements(IEtree)
-
-    def __init__(self):
-        from lxml import etree
-        self.etree = etree
-
-    def tostring(self, element, encoding = None):
-        """LXML loses the namespace information whenever we print out an
-        element who namespace was defined in 
-        """
-        return self.etree.tostring(copy.copy(element), encoding)



More information about the Checkins mailing list