[Checkins] SVN: zope.traversing/trunk/ Replaced a test dependency on zope.app.zptpage with a dependency on zope.pagetemplate - this one doesn't win a beauty contest ; )

Hanno Schlichting hannosch at hannosch.eu
Tue Dec 15 18:25:57 EST 2009


Log message for revision 106594:
  Replaced a test dependency on zope.app.zptpage with a dependency on zope.pagetemplate - this one doesn't win a beauty contest ;)
  

Changed:
  U   zope.traversing/trunk/CHANGES.txt
  U   zope.traversing/trunk/setup.py
  U   zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml
  U   zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py

-=-
Modified: zope.traversing/trunk/CHANGES.txt
===================================================================
--- zope.traversing/trunk/CHANGES.txt	2009-12-15 21:57:36 UTC (rev 106593)
+++ zope.traversing/trunk/CHANGES.txt	2009-12-15 23:25:57 UTC (rev 106594)
@@ -2,9 +2,11 @@
 Changes
 =======
 
-3.9.1 (unreleased)
-------------------
+3.10.0 (unreleased)
+-------------------
 
+- Replaced a test dependency on zope.app.zptpage with a dependency on
+  zope.pagetemplate.
 
 3.9.0 (2009-12-15)
 ------------------

Modified: zope.traversing/trunk/setup.py
===================================================================
--- zope.traversing/trunk/setup.py	2009-12-15 21:57:36 UTC (rev 106593)
+++ zope.traversing/trunk/setup.py	2009-12-15 23:25:57 UTC (rev 106594)
@@ -27,7 +27,7 @@
                     open('CHANGES.txt').read())
 
 setup(name='zope.traversing',
-      version = '3.9.1dev',
+      version = '3.10.0dev',
       url='http://pypi.python.org/pypi/zope.traversing',
       license='ZPL 2.1',
       author='Zope Corporation and Contributors',
@@ -41,10 +41,10 @@
       extras_require = dict(test=['zope.app.testing',
                                   'zope.app.securitypolicy',
                                   'zope.app.zcmlfiles',
-                                  'zope.app.zptpage',
                                   'zope.app.applicationcontrol>=3.5.0',
                                   'zope.app.component',
                                   'zope.container',
+                                  'zope.pagetemplate',
                                   'zope.site',
                                   # The tests expect a spec-compliant TAL
                                   # interpreter as found in zope.tal 3.5.0

Modified: zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml
===================================================================
--- zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml	2009-12-15 21:57:36 UTC (rev 106593)
+++ zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml	2009-12-15 23:25:57 UTC (rev 106594)
@@ -1,5 +1,6 @@
 <configure
    xmlns="http://namespaces.zope.org/zope"
+   xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="zope"
    package="zope.traversing"
    >
@@ -8,8 +9,25 @@
   <!-- used for functional testing setup -->
 
   <include package="zope.app.zcmlfiles" />
-  <include package="zope.app.zptpage"/>
 
+  <browser:page
+      name="index.html"
+      for="zope.traversing.tests.test_vhosting.MyPageTemplate"
+      class="zope.traversing.tests.test_vhosting.MyPageEval"
+      attribute="index"
+      permission="zope.View"
+      />
+
+  <class class="zope.traversing.tests.test_vhosting.MyPageTemplate">
+    <factory
+        id="zope.traversing.tests.test_vhosting.MyPageTemplate"
+        />
+    <require
+        permission="zope.View"
+        attributes="__call__ render"
+        />
+  </class>
+
   <!-- Principals -->
 
   <unauthenticatedPrincipal

Modified: zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py
===================================================================
--- zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py	2009-12-15 21:57:36 UTC (rev 106593)
+++ zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py	2009-12-15 23:25:57 UTC (rev 106594)
@@ -16,26 +16,56 @@
 $Id$
 """
 import unittest
+
 import transaction
-from zope.traversing.api import traverse
-from zope.traversing.testing import browserResource
+from persistent import Persistent
+
+from zope.container.contained import Contained
+from zope.pagetemplate.pagetemplate import PageTemplate
+from zope.pagetemplate.engine import AppPT
 from zope.security.checker import defineChecker, NamesChecker, NoProxy
 from zope.security.checker import _checkers, undefineChecker
+from zope.site.folder import Folder
+from zope.traversing.api import traverse
+from zope.traversing.testing import browserResource
+from zope.traversing.tests.layer import TraversingLayer
 
 from zope.app.testing import functional
 from zope.app.publisher.browser.resource import Resource
-from zope.container.contained import Contained
-from zope.app.zptpage.zptpage import ZPTPage
-from zope.site.folder import Folder
-from zope.traversing.tests.layer import TraversingLayer
 
+
 class MyObj(Contained):
     def __getitem__(self, key):
         return traverse(self, '/foo/bar/' + key)
 
 
+class MyPageTemplate(AppPT, PageTemplate, Persistent):
+
+    def pt_getContext(self, instance, request, **_kw):
+        # instance is a View component
+        namespace = super(MyPageTemplate, self).pt_getContext(**_kw)
+        namespace['template'] = self
+        namespace['request'] = request
+        namespace['container'] = namespace['context'] = instance
+        return namespace
+
+    def render(self, instance, request, *args, **kw):
+        return self.pt_render(self.pt_getContext(instance, request))
+
+
+class MyPageEval(object):
+
+    def index(self, **kw):
+        """Call a Page Template"""
+        template = self.context
+        request = self.request
+        return template.render(template.__parent__, request, **kw)
+
+
 class TestVirtualHosting(functional.BrowserTestCase):
 
+    layer = TraversingLayer
+
     def setUp(self):
         functional.BrowserTestCase.setUp(self)
         defineChecker(MyObj, NoProxy)
@@ -46,57 +76,23 @@
 
     def test_request_url(self):
         self.addPage('/pt', u'<span tal:replace="request/URL"/>')
-        self.verify('/pt', 'http://localhost/pt')
+        self.verify('/pt', 'http://localhost/pt/index.html')
         self.verify('/++vh++/++/pt',
-                    'http://localhost/pt')
+                    'http://localhost/pt/index.html')
         self.verify('/++vh++https:localhost:443/++/pt',
-                    'https://localhost/pt')
+                    'https://localhost/pt/index.html')
         self.verify('/++vh++https:localhost:443/fake/folders/++/pt',
-                    'https://localhost/fake/folders/pt')
+                    'https://localhost/fake/folders/pt/index.html')
 
         self.addPage('/foo/bar/pt', u'<span tal:replace="request/URL"/>')
-        self.verify('/foo/bar/pt', 'http://localhost/foo/bar/pt')
+        self.verify('/foo/bar/pt', 'http://localhost/foo/bar/pt/index.html')
         self.verify('/foo/bar/++vh++/++/pt',
-                    'http://localhost/pt')
+                    'http://localhost/pt/index.html')
         self.verify('/foo/bar/++vh++https:localhost:443/++/pt',
-                    'https://localhost/pt')
+                    'https://localhost/pt/index.html')
         self.verify('/foo/++vh++https:localhost:443/fake/folders/++/bar/pt',
-                    'https://localhost/fake/folders/bar/pt')
+                    'https://localhost/fake/folders/bar/pt/index.html')
 
-    def test_request_base(self):
-        self.addPage('/pt', u'<head></head>')
-        self.verify('/pt/',
-                    '<head>\n<base href="http://localhost/pt" />\n'
-                    '</head>')
-        self.verify('/++vh++/++/pt/',
-                    '<head>\n<base href="http://localhost/pt" />\n'
-                    '</head>')
-        self.verify('/++vh++https:localhost:443/++/pt/',
-                    '<head>\n'
-                    '<base href="https://localhost/pt" />'
-                    '\n</head>')
-        self.verify('/++vh++https:localhost:443/fake/folders/++/pt/',
-                    '<head>\n<base href='
-                    '"https://localhost/fake/folders/pt" />'
-                    '\n</head>')
-
-        self.addPage('/foo/bar/pt', u'<head></head>')
-        self.verify('/foo/bar/pt/',
-                    '<head>\n<base '
-                    'href="http://localhost/foo/bar/pt" />\n'
-                    '</head>')
-        self.verify('/foo/bar/++vh++/++/pt/',
-                    '<head>\n<base href="http://localhost/pt" />\n'
-                    '</head>')
-        self.verify('/foo/bar/++vh++https:localhost:443/++/pt/',
-                    '<head>\n'
-                    '<base href="https://localhost/pt" />'
-                    '\n</head>')
-        self.verify('/foo/++vh++https:localhost:443/fake/folders/++/bar/pt/',
-                    '<head>\n<base href='
-                    '"https://localhost/fake/folders/bar/pt" />'
-                    '\n</head>')
-
     def test_request_redirect(self):
         self.addPage('/foo/index.html', u'Spam')
         self.verifyRedirect('/foo', 'http://localhost/foo/index.html')
@@ -106,24 +102,24 @@
                             'https://localhost/bar/index.html')
 
     def test_absolute_url(self):
-        self.addPage('/pt', u'<span tal:replace="template/@@absolute_url"/>')
-        self.verify('/pt', 'http://localhost/pt')
+        self.addPage('/pt', u'<span tal:replace="context/@@absolute_url"/>')
+        self.verify('/pt', 'http://localhost')
         self.verify('/++vh++/++/pt',
-                    'http://localhost/pt')
+                    'http://localhost')
         self.verify('/++vh++https:localhost:443/++/pt',
-                    'https://localhost/pt')
+                    'https://localhost')
         self.verify('/++vh++https:localhost:443/fake/folders/++/pt',
-                    'https://localhost/fake/folders/pt')
+                    'https://localhost/fake/folders')
 
         self.addPage('/foo/bar/pt',
-                     u'<span tal:replace="template/@@absolute_url"/>')
-        self.verify('/foo/bar/pt', 'http://localhost/foo/bar/pt')
+                     u'<span tal:replace="context/@@absolute_url"/>')
+        self.verify('/foo/bar/pt', 'http://localhost/foo/bar')
         self.verify('/foo/bar/++vh++/++/pt',
-                    'http://localhost/pt')
+                    'http://localhost')
         self.verify('/foo/bar/++vh++https:localhost:443/++/pt',
-                    'https://localhost/pt')
+                    'https://localhost')
         self.verify('/foo/++vh++https:localhost:443/fake/folders/++/bar/pt',
-                    'https://localhost/fake/folders/bar/pt')
+                    'https://localhost/fake/folders/bar')
 
     def test_absolute_url_absolute_traverse(self):
         self.createObject('/foo/bar/obj', MyObj())
@@ -166,8 +162,8 @@
         transaction.commit()
 
     def addPage(self, path, content):
-        page = ZPTPage()
-        page.source = content
+        page = MyPageTemplate()
+        page.pt_edit(content, 'text/html')
         self.createObject(path, page)
 
     def verify(self, path, content):
@@ -183,7 +179,6 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    TestVirtualHosting.layer = TraversingLayer
     suite.addTest(unittest.makeSuite(TestVirtualHosting))
     return suite
 



More information about the checkins mailing list