summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Richter <srichter@cipherhealth.com>2013-02-20 23:57:18 -0500
committerStephan Richter <srichter@cipherhealth.com>2013-02-20 23:57:18 -0500
commit02ead7794791f2dabbdbad08d484936d05a8508e (patch)
tree9390f2627867a87b8d67aaf9b783fe8df0598175
parent66264967c7eb7d9e42d98ad511ab0d60c3058bcf (diff)
downloadzope-traversing-02ead7794791f2dabbdbad08d484936d05a8508e.tar.gz
Remove various testing dependencies, which breaks some circular
dependencies.
-rw-r--r--CHANGES.txt13
-rw-r--r--setup.py4
-rw-r--r--src/zope/traversing/browser/configure.zcml21
-rw-r--r--src/zope/traversing/tests/ftesting.zcml28
-rw-r--r--src/zope/traversing/tests/test_vhosting.py76
5 files changed, 100 insertions, 42 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 29c6894..88b87b6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -5,7 +5,12 @@ Changes
4.0.0dev (unreleased)
---------------------
-- Nothing changed yet.
+- Removed ``zope.pagetemplate`` testing dependency to break another circular
+ dependency.
+
+- Removed ``zope.browserpage`` (ZCML) dependency by using low-level directives.
+
+- Removed ``zope.site`` testing dependency.
4.0.0a1 (2013-02-20)
@@ -41,8 +46,8 @@ Changes
- When a ``__parent__`` attribute is available on an object, it is
always used for absolute URL construction, and no ILocation adapter
lookup is performed for it. This was the previous behavior but was
- broken (around 3.5?) due to dependency refactoring.
-
+ broken (around 3.5?) due to dependency refactoring.
+
If the object provides no ``__parent__`` then an ILocation adapter
lookup will be performed. This will always succeed as zope.location
provides a default LocationProxy for everything, but more specific
@@ -221,7 +226,7 @@ Changes
- Added a traverer for ++skin++ for XMLRPC skins (IXMLRPCSkinType). This also
means that the normal ++skin++ namespace handler is only bound to
- IBrowserRequest.
+ IBrowserRequest.
- Resolved the dependency on zope.app.applicationcontrol by importing the
application controller only if the package is available.
diff --git a/setup.py b/setup.py
index d840b29..bd19281 100644
--- a/setup.py
+++ b/setup.py
@@ -67,20 +67,18 @@ setup(name='zope.traversing',
package_dir = {'': 'src'},
namespace_packages=['zope',],
extras_require = dict(test=[
- 'ZODB',
'zope.annotation',
'zope.browserresource[zcml]>=3.12',
'zope.component[zcml]',
'zope.configuration',
'zope.container',
- 'zope.pagetemplate',
'zope.security[zcml]>=3.8',
+ 'zope.tales',
'zope.testing',
]),
install_requires=[
'setuptools',
'six',
- 'zope.browserpage',
'zope.component',
'zope.i18n',
'zope.i18nmessageid',
diff --git a/src/zope/traversing/browser/configure.zcml b/src/zope/traversing/browser/configure.zcml
index 9e6c0cc..197d0fe 100644
--- a/src/zope/traversing/browser/configure.zcml
+++ b/src/zope/traversing/browser/configure.zcml
@@ -3,7 +3,6 @@
xmlns:browser="http://namespaces.zope.org/browser">
<include file="meta.zcml" package="zope.component" />
- <include file="meta.zcml" package="zope.browserpage" />
<view
for="*"
@@ -39,20 +38,28 @@
provides=".interfaces.IAbsoluteURL"
/>
- <browser:page
+ <view
for="*"
name="absolute_url"
- class=".AbsoluteURL"
+ factory=".AbsoluteURL"
+ type="zope.publisher.interfaces.browser.IDefaultBrowserLayer"
permission="zope.Public"
- allowed_interface=".interfaces.IAbsoluteURL"
/>
- <browser:page
+ <class class=".AbsoluteURL">
+ <allow interface=".interfaces.IAbsoluteURL" />
+ </class>
+
+ <view
for="zope.location.interfaces.IRoot"
name="absolute_url"
- class=".SiteAbsoluteURL"
+ factory=".SiteAbsoluteURL"
+ type="zope.publisher.interfaces.browser.IDefaultBrowserLayer"
permission="zope.Public"
- allowed_interface=".interfaces.IAbsoluteURL"
/>
+ <class class=".SiteAbsoluteURL">
+ <allow interface=".interfaces.IAbsoluteURL" />
+ </class>
+
</configure>
diff --git a/src/zope/traversing/tests/ftesting.zcml b/src/zope/traversing/tests/ftesting.zcml
index a97174d..139a1e5 100644
--- a/src/zope/traversing/tests/ftesting.zcml
+++ b/src/zope/traversing/tests/ftesting.zcml
@@ -5,7 +5,6 @@
package="zope.traversing"
>
- <include package="zope.browserpage" file="meta.zcml" />
<include package="zope.publisher" file="meta.zcml" />
<include package="zope.security" file="meta.zcml" />
@@ -18,24 +17,33 @@
<browser:defaultView name="index.html" />
<include package="zope.traversing.browser" />
- <browser:page
+ <view
+ name="index.html"
for="zope.traversing.tests.test_vhosting.IFolder"
+ factory="zope.traversing.tests.test_vhosting.MyFolderPage"
+ type="zope.publisher.interfaces.browser.IDefaultBrowserLayer"
permission="zope.View"
- class="zope.traversing.tests.test_vhosting.MyFolderPage"
- name="index.html" attribute="index"
/>
- <browser:page
+ <class class="zope.traversing.tests.test_vhosting.MyFolderPage">
+ <allow attributes="__call__" />
+ </class>
+
+ <view
name="index.html"
- for="zope.traversing.tests.test_vhosting.MyPageTemplate"
- class="zope.traversing.tests.test_vhosting.MyPageEval"
- attribute="index"
+ for="zope.traversing.tests.test_vhosting.MyTalesPage"
+ factory="zope.traversing.tests.test_vhosting.MyPageEval"
+ type="zope.publisher.interfaces.browser.IDefaultBrowserLayer"
permission="zope.View"
/>
- <class class="zope.traversing.tests.test_vhosting.MyPageTemplate">
+ <class class="zope.traversing.tests.test_vhosting.MyPageEval">
+ <allow attributes="__call__" />
+ </class>
+
+ <class class="zope.traversing.tests.test_vhosting.MyTalesPage">
<factory
- id="zope.traversing.tests.test_vhosting.MyPageTemplate"
+ id="zope.traversing.tests.test_vhosting.MyTalesPage"
/>
<require
permission="zope.View"
diff --git a/src/zope/traversing/tests/test_vhosting.py b/src/zope/traversing/tests/test_vhosting.py
index c759adc..4a3af97 100644
--- a/src/zope/traversing/tests/test_vhosting.py
+++ b/src/zope/traversing/tests/test_vhosting.py
@@ -29,15 +29,16 @@ from zope.container import btree
from zope.container.contained import Contained
from zope.container.interfaces import IContainer
from zope.location.interfaces import IRoot
-from zope.pagetemplate.pagetemplate import PageTemplate
-from zope.pagetemplate.engine import AppPT
-from zope.publisher.browser import BrowserRequest
+from zope.publisher.browser import BrowserRequest, BrowserView
from zope.publisher.publish import publish
from zope.publisher.skinnable import setDefaultSkin
from zope.security.checker import defineChecker, NamesChecker, NoProxy
from zope.security.checker import _checkers, undefineChecker
+from zope.tales import expressions
+from zope.tales.tales import ExpressionEngine
from zope.testing.cleanup import cleanUp
+from zope.traversing.adapters import traversePathElement
from zope.traversing.api import traverse
from zope.traversing.testing import browserResource
@@ -59,36 +60,75 @@ class RootFolder(Folder):
pass
-class MyPageTemplate(AppPT, PageTemplate):
+# Copy some code from zope.pagetemplate to avoid the depedency (break circle)
+class ZopeTraverser(object):
+
+ def __call__(self, object, path_items, econtext):
+ request = econtext._vars_stack[0].get('request', None)
+ path_items = list(path_items)
+ path_items.reverse()
+
+ while path_items:
+ name = path_items.pop()
+ if getattr(object, '__class__', None) == dict:
+ object = object[name]
+ else:
+ object = traversePathElement(object, name, path_items,
+ request=request)
+ return object
+zopeTraverser = ZopeTraverser()
+
+class PathExpr(expressions.PathExpr):
+
+ def __init__(self, name, expr, engine):
+ super(PathExpr, self).__init__(name, expr, engine, zopeTraverser)
+
+def Engine():
+ e = ExpressionEngine()
+ for pt in PathExpr._default_type_names:
+ e.registerType(pt, PathExpr)
+ return e
+
+Engine = Engine()
+
+class MyTalesPage(object):
+
+ def __init__(self, source):
+ self.source = source
def pt_getContext(self, instance, request, **_kw):
# instance is a View component
- namespace = super(MyPageTemplate, self).pt_getContext(**_kw)
+ namespace = {}
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))
+ context = self.pt_getContext(instance, request)
+ code = Engine.compile(self.source)
+ return str(code(Engine.getContext(context)))
-class MyPageEval(object):
+class MyPageEval(BrowserView):
- def index(self, **kw):
+ def __call__(self, **kw):
"""Call a Page Template"""
template = self.context
request = self.request
return template.render(template.__parent__, request, **kw)
+ index = __call__
-class MyFolderPage(object):
+class MyFolderPage(BrowserView):
- def index(self, **kw):
+ def __call__(self, **kw):
"""My folder page"""
self.request.response.redirect('index.html')
return ''
+ index = __call__
+
class TestVirtualHosting(unittest.TestCase):
@@ -120,7 +160,7 @@ class TestVirtualHosting(unittest.TestCase):
return publish(self.makeRequest(path)).response
def test_request_url(self):
- self.addPage('/pt', u'<span tal:replace="request/URL"/>')
+ self.addPage('/pt', u'request/URL')
self.verify('/pt', 'http://localhost/pt/index.html')
self.verify('/++vh++/++/pt',
'http://localhost/pt/index.html')
@@ -129,7 +169,7 @@ class TestVirtualHosting(unittest.TestCase):
self.verify('/++vh++https:localhost:443/fake/folders/++/pt',
'https://localhost/fake/folders/pt/index.html')
- self.addPage('/foo/bar/pt', u'<span tal:replace="request/URL"/>')
+ self.addPage('/foo/bar/pt', u'request/URL')
self.verify('/foo/bar/pt', 'http://localhost/foo/bar/pt/index.html')
self.verify('/foo/bar/++vh++/++/pt',
'http://localhost/pt/index.html')
@@ -147,7 +187,7 @@ class TestVirtualHosting(unittest.TestCase):
'https://localhost/bar/index.html')
def test_absolute_url(self):
- self.addPage('/pt', u'<span tal:replace="context/@@absolute_url"/>')
+ self.addPage('/pt', u'context/@@absolute_url')
self.verify('/pt', 'http://localhost')
self.verify('/++vh++/++/pt',
'http://localhost')
@@ -157,7 +197,7 @@ class TestVirtualHosting(unittest.TestCase):
'https://localhost/fake/folders')
self.addPage('/foo/bar/pt',
- u'<span tal:replace="context/@@absolute_url"/>')
+ u'context/@@absolute_url')
self.verify('/foo/bar/pt', 'http://localhost/foo/bar')
self.verify('/foo/bar/++vh++/++/pt',
'http://localhost')
@@ -169,7 +209,7 @@ class TestVirtualHosting(unittest.TestCase):
def test_absolute_url_absolute_traverse(self):
self.createObject('/foo/bar/obj', MyObj())
self.addPage('/foo/bar/pt',
- u'<span tal:replace="container/obj/pt/@@absolute_url"/>')
+ u'container/obj/pt/@@absolute_url')
self.verify('/foo/bar/pt', 'http://localhost/foo/bar/pt')
self.verify('/foo/++vh++https:localhost:443/++/bar/pt',
'https://localhost/bar/pt')
@@ -180,7 +220,7 @@ class TestVirtualHosting(unittest.TestCase):
if Resource not in _checkers:
defineChecker(Resource, NamesChecker(['__call__']))
self.addPage(u'/foo/bar/pt',
- u'<span tal:replace="context/++resource++quux" />')
+ u'context/++resource++quux')
self.verify(u'/foo/bar/pt', u'http://localhost/@@/quux')
self.verify(u'/foo/++vh++https:localhost:443/fake/folders/++/bar/pt',
u'https://localhost/fake/folders/@@/quux')
@@ -207,8 +247,7 @@ class TestVirtualHosting(unittest.TestCase):
transaction.commit()
def addPage(self, path, content):
- page = MyPageTemplate()
- page.pt_edit(content, 'text/html')
+ page = MyTalesPage(content)
self.createObject(path, page)
def verify(self, path, content):
@@ -254,6 +293,7 @@ class DummyPublication:
view = queryMultiAdapter((ob, request), name=name)
if view is None:
from zope.publisher.interfaces import NotFound
+ import pdb; pdb.set_trace()
raise NotFound(ob, name)
return view
else: