[Zope3-checkins] CVS: Zope3/src/zope/app/dav/tests - test_mkcol.py:1.4.6.1 test_propfind.py:1.9.6.1

Jim Fulton cvs-admin at zope.org
Sun Nov 9 11:08:48 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/dav/tests
In directory cvs.zope.org:/tmp/cvs-serv15349/src/zope/app/dav/tests

Modified Files:
      Tag: adaptergeddon-branch
	test_mkcol.py test_propfind.py 
Log Message:
Created a global presentation service that replaces the 
global view, resource, and skin services.

Now look up presentation components by adapting from a request type,
rather than adapting to a presentation type.





=== Zope3/src/zope/app/dav/tests/test_mkcol.py 1.4 => 1.4.6.1 ===
--- Zope3/src/zope/app/dav/tests/test_mkcol.py:1.4	Sun Sep 21 13:30:45 2003
+++ Zope3/src/zope/app/dav/tests/test_mkcol.py	Sun Nov  9 11:08:17 2003
@@ -49,7 +49,7 @@
         root = self.rootFolder
         request = _createRequest('')
         container = traverse(root, 'folder1')
-        file = File('bla', 'text/plain', 'bla')
+        file = File('bla', 'text/plain', 'bla', container)
         container['bla'] = file
         file = traverse(container, 'bla')
         nr = NullResource(file, 'mkcol_test')


=== Zope3/src/zope/app/dav/tests/test_propfind.py 1.9 => 1.9.6.1 ===
--- Zope3/src/zope/app/dav/tests/test_propfind.py:1.9	Sun Sep 21 13:30:45 2003
+++ Zope3/src/zope/app/dav/tests/test_propfind.py	Sun Nov  9 11:08:17 2003
@@ -16,18 +16,19 @@
 """
 __metaclass__ = type
 
+from zope.app import zapi
+from zope.app.tests import ztapi
 from datetime import datetime
 from unittest import TestCase, TestSuite, main, makeSuite
 from StringIO import StringIO
 from zope.component import getService, getView, getAdapter
-from zope.app.services.servicenames import Adapters, Views
+from zope.app.services.servicenames import Adapters
 from zope.app.traversing import traverse
 from zope.publisher.browser import TestRequest
 from zope.app.interfaces.file import IWriteFile
 from zope.app.interfaces.content.zpt import IZPTPage
 from zope.app.services.tests.placefulsetup import PlacefulSetup
-from zope.publisher.interfaces.browser import IBrowserPresentation
-from zope.publisher.interfaces.http import IHTTPPresentation
+from zope.publisher.interfaces.http import IHTTPRequest
 from zope.app.browser.absoluteurl import AbsoluteURL
 from zope.pagetemplate.tests.util import normalize_xml
 from zope.schema import getFieldNamesInOrder
@@ -42,37 +43,42 @@
 from zope.app.interfaces.annotation import IAnnotatable, IAnnotations
 from zope.app.attributeannotations import AttributeAnnotations
 from zope.interface import implements
+import zope.app.location
 
-class Folder:
+class Folder(zope.app.location.Location):
 
     implements(IReadContainer)
 
-    def __init__(self, name, level=0):
-        self.name = name
+    def __init__(self, name, level=0, parent=None):
+        self.name = self.__name__ = name
         self.level=level
+        self.__parent__ = parent
 
     def items(self):
         if self.level == 2:
-            return (('last', File('last', 'text/plain', 'blablabla')),)
+            return (('last', File('last', 'text/plain', 'blablabla', self)),)
         result = []
         for i in range(1, 3):
-            result.append((str(i), File(str(i), 'text/plain', 'blablabla')))
-        result.append(('sub1', Folder('sub1', level=self.level+1)))
+            result.append((str(i),
+                           File(str(i), 'text/plain', 'blablabla', self)))
+        result.append(('sub1',
+                       Folder('sub1', level=self.level+1, parent=self)))
         return tuple(result)
 
-class File:
+class File(zope.app.location.Location):
 
     implements(IWriteFile)
 
-    def __init__(self, name, content_type, data):
-        self.name = name
+    def __init__(self, name, content_type, data, parent=None):
+        self.name = self.__name__ = name
         self.content_type = content_type
         self.data = data
+        self.__parent__ = parent
 
     def write(self, data):
         self.data = data
 
-class FooZPT:
+class FooZPT(zope.app.location.Location):
 
     implements(IAnnotatable, IZPTPage)
 
@@ -124,24 +130,19 @@
         root['folder'] = folder
         self.zpt = traverse(root, 'zpt')
         self.file = traverse(root, 'file')
-        provideView = getService(None, Views).provideView
-        setDefaultView = getService(None, Views).setDefaultViewName
-        provideView(None, 'absolute_url', IHTTPPresentation,
-                    [AbsoluteURL])
-        provideView(None, 'PROPFIND', IHTTPPresentation,
-                    [propfind.PROPFIND])
-        provideView(IText, 'view', IBrowserPresentation,
-                    [TextDAVWidget])
-        provideView(ITextLine, 'view', IBrowserPresentation,
-                    [TextDAVWidget])
-        provideView(IDatetime, 'view', IBrowserPresentation,
-                    [TextDAVWidget])
-        provideView(ISequence, 'view', IBrowserPresentation,
-                    [SequenceDAVWidget])
-        setDefaultView(IText, IBrowserPresentation, 'view')
-        setDefaultView(ITextLine, IBrowserPresentation, 'view')
-        setDefaultView(IDatetime, IBrowserPresentation, 'view')
-        setDefaultView(ISequence, IBrowserPresentation, 'view')
+        ps = zapi.getService(None, zapi.servicenames.Presentation)
+        ps.provideView(None, 'absolute_url', IHTTPRequest,
+                       [AbsoluteURL])
+        ps.provideView(None, 'PROPFIND', IHTTPRequest,
+                       [propfind.PROPFIND])
+        ztapi.browserView(IText, 'view', [TextDAVWidget])
+        ztapi.browserView(ITextLine, 'view', [TextDAVWidget])
+        ztapi.browserView(IDatetime, 'view', [TextDAVWidget])
+        ztapi.browserView(ISequence, 'view', [SequenceDAVWidget])
+        ztapi.setDefaultViewName(IText, 'view')
+        ztapi.setDefaultViewName(ITextLine, 'view')
+        ztapi.setDefaultViewName(IDatetime, 'view')
+        ztapi.setDefaultViewName(ISequence, 'view')
         provideAdapter = getService(None, Adapters).provideAdapter
         provideAdapter(IAnnotatable, IAnnotations, AttributeAnnotations)
         provideAdapter(IAnnotatable, IZopeDublinCore, ZDCAnnotatableAdapter)




More information about the Zope3-Checkins mailing list