Commit 5d03ec13 authored by 's avatar

- reverted r122056 and merged test improvements from 2.13 branch

(see https://mail.zope.org/pipermail/zope-dev/2011-November/043733.html)
parents 3829b68e 592d22c3
...@@ -136,15 +136,6 @@ Restructuring ...@@ -136,15 +136,6 @@ Restructuring
`lib/python` and `Products` from the default. You can continue to manually `lib/python` and `Products` from the default. You can continue to manually
add these back. add these back.
- Removed the rarely used support for the `++skin++` traverser. You can enable
it in your own applications by defining::
<adapter
name="skin"
for="* zope.publisher.interfaces.IRequest"
provides="zope.traversing.interfaces.ITraversable"
factory="zope.traversing.namespace.skin" />
- Five.browser: Marked `processInputs` and `setPageEncoding` as deprecated. - Five.browser: Marked `processInputs` and `setPageEncoding` as deprecated.
`processInputs` was replaced by the `postProcessInputs` request method and `processInputs` was replaced by the `postProcessInputs` request method and
the charset negotiation done by `setPageEncoding` was never fully supported. the charset negotiation done by `setPageEncoding` was never fully supported.
......
...@@ -18,45 +18,59 @@ from Products.Five import BrowserView ...@@ -18,45 +18,59 @@ from Products.Five import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
class SimpleView(BrowserView): class SimpleView(BrowserView):
"""More docstring. Please Zope""" """More docstring. Please Zope"""
def eagle(self): def eagle(self):
"""Docstring""" """Docstring"""
return u"The eagle has landed" return u"The eagle has landed"
def eagle2(self):
"""Docstring"""
return u"The eagle has landed:\n%s" % self.context.absolute_url()
def mouse(self): def mouse(self):
"""Docstring""" """Docstring"""
return u"The mouse has been eaten by the eagle" return u"The mouse has been eaten by the eagle"
class FancyView(BrowserView): class FancyView(BrowserView):
"""Fancy, fancy stuff""" """Fancy, fancy stuff"""
def view(self): def view(self):
return u"Fancy, fancy" return u"Fancy, fancy"
class CallView(BrowserView): class CallView(BrowserView):
def __call__(self): def __call__(self):
return u"I was __call__()'ed" return u"I was __call__()'ed"
class PermissionView(BrowserView, SimpleItem): class PermissionView(BrowserView, SimpleItem):
def __call__(self): def __call__(self):
return u"I was __call__()'ed" return u"I was __call__()'ed"
class CallTemplate(BrowserView): class CallTemplate(BrowserView):
__call__ = ViewPageTemplateFile('falcon.pt') __call__ = ViewPageTemplateFile('falcon.pt')
class CallableNoDocstring: class CallableNoDocstring:
def __call__(self): def __call__(self):
return u"No docstring" return u"No docstring"
def function_no_docstring(self): def function_no_docstring(self):
return u"No docstring" return u"No docstring"
class NoDocstringView(BrowserView): class NoDocstringView(BrowserView):
def method(self): def method(self):
...@@ -66,7 +80,9 @@ class NoDocstringView(BrowserView): ...@@ -66,7 +80,9 @@ class NoDocstringView(BrowserView):
object = CallableNoDocstring() object = CallableNoDocstring()
class NewStyleClass(object): class NewStyleClass(object):
""" """
This is a testclass to verify that new style classes work This is a testclass to verify that new style classes work
in browser:page in browser:page
......
##############################################################################
#
# Copyright (c) 2006 Zope Foundation 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 skins
"""
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
class ITestSkin(IDefaultBrowserLayer):
pass
Test layer and skin support
===========================
Let's register a test layer and test skin:
>>> import Products.Five.browser.tests
>>> from Zope2.App import zcml
>>> zcml.load_config("configure.zcml", Products.Five)
>>> zcml.load_config("skin.zcml", package=Products.Five.browser.tests)
Let's add a test object that we'll access the test page from:
>>> from Products.Five.tests.testing.simplecontent import manage_addSimpleContent
>>> manage_addSimpleContent(self.folder, 'testoid', 'Testoid')
The view was registered on a different layer than 'default', that's
why we can't access it straight away:
>>> print http(r"""
... GET /test_folder_1_/testoid/eagle.html HTTP/1.1
... """)
HTTP/1.1 404 Not Found
...
It works when we explicitly use the skin that includes that layer:
>>> print http(r"""
... GET /++skin++TestSkin/test_folder_1_/testoid/eagle.html HTTP/1.1
... """)
HTTP/1.1 200 OK
...
The eagle has landed:
http://localhost/++skin++TestSkin/test_folder_1_/testoid
Or when we make that skin the default skin:
>>> zcml.load_string('''
... <browser:defaultSkin
... xmlns:browser="http://namespaces.zope.org/browser"
... name="TestSkin" />
... ''')
>>> print http(r"""
... GET /test_folder_1_/testoid/eagle.html HTTP/1.1
... """)
HTTP/1.1 200 OK
...
The eagle has landed:
http://localhost/test_folder_1_/testoid
Clean up
--------
>>> from zope.component.testing import tearDown
>>> tearDown()
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta"
xmlns:browser="http://namespaces.zope.org/browser">
<!-- make the zope2.Public permission work -->
<meta:redefinePermission from="zope2.Public" to="zope.Public" />
<interface
interface=".skin.ITestSkin"
type="zope.publisher.interfaces.browser.IBrowserSkinType"
name="TestSkin"
/>
<browser:page
for="Products.Five.tests.testing.simplecontent.ISimpleContent"
class=".pages.SimpleView"
attribute="eagle2"
name="eagle.html"
permission="zope2.Public"
layer=".skin.ITestSkin"
/>
</configure>
##############################################################################
#
# Copyright (c) 2005 Zope Foundation 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 browser pages
"""
def test_suite():
from Testing.ZopeTestCase import FunctionalDocFileSuite
return FunctionalDocFileSuite('skin.txt',
package='Products.Five.browser.tests')
...@@ -37,6 +37,13 @@ ...@@ -37,6 +37,13 @@
factory="zope.traversing.namespace.adapter" factory="zope.traversing.namespace.adapter"
/> />
<adapter
name="skin"
for="* zope.publisher.interfaces.IRequest"
provides="zope.traversing.interfaces.ITraversable"
factory="zope.traversing.namespace.skin"
/>
<adapter <adapter
name="resource" name="resource"
for="* zope.publisher.interfaces.IRequest" for="* zope.publisher.interfaces.IRequest"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment