Commit 091ed249 authored by Hanno Schlichting's avatar Hanno Schlichting

Removed even more long deprecated stuff

parent 688dde26
......@@ -15,9 +15,6 @@
$Id$
"""
from zope.interface import Interface, implements
from zope.component.interfaces import ComponentLookupError
from zope.app.publisher.browser import getDefaultViewName
import Acquisition
......@@ -43,50 +40,3 @@ class AcquisitionBBB(object):
def aq_inContextOf(self, *args, **kw):
return Acquisition.aq_inContextOf(self, *args, **kw)
class IBrowserDefault(Interface):
"""Provide a hook for deciding about the default view for an object"""
def defaultView(self, request):
"""Return the object to be published
(usually self) and a sequence of names to traverse to
find the method to be published.
"""
class BrowserDefault(object):
implements(IBrowserDefault)
def __init__(self, context):
self.context = context
def defaultView(self, request):
context = self.context
try:
name = getDefaultViewName(context, request)
return context, [name,]
except ComponentLookupError:
return context, None
class Traversable:
"""A mixin to make an object traversable"""
__five_traversable__ = True
def __bobo_traverse__(self, REQUEST, name):
"""Hook for Zope 2 traversal
This method is called by Zope 2's ZPublisher upon traversal.
It allows us to trick it into faking the Zope 3 traversal system
by using an ITraverser adapter.
"""
try:
return getattr(self, name)
except AttributeError:
pass
try:
return self[name]
except (KeyError, IndexError, TypeError, AttributeError):
pass
raise AttributeError(name)
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">
<!-- BBB 2006/05/01 - to be removed after 12 months -->
<browser:defaultView
for="Products.Five.bbb.IBrowserDefault"
name="index.html"
/>
<interface
interface="zope.publisher.interfaces.browser.IBrowserSkinType"
/>
......@@ -15,13 +9,6 @@
interface="zope.app.publisher.interfaces.browser.IMenuItemType"
/>
<!-- BBB 2006/02/18, to be removed after 12 months -->
<browser:layer
name="default"
interface="zope.publisher.interfaces.browser.IDefaultBrowserLayer"
bbb_aware="true"
/>
<browser:page
for="*"
name="absolute_url"
......
......@@ -113,13 +113,6 @@ Test macro access from ZPT pages:
>>> view()
u'<html><head><title>bird macro</title></head><body>Color: gray</body></html>\n'
Test whether old-style direct traversal still works with a
five:traversable class:
>>> old_view = self.folder.unrestrictedTraverse('testoid/direct')
>>> old_view()
'Direct traversal worked'
test_zpt_things:
>>> view = self.folder.unrestrictedTraverse('testoid/condor.html')
......
......@@ -23,13 +23,3 @@ class IMenuItemType(IInterface):
Menu item types are interfaces that define classes of
menu items.
"""
# BBB 2006/05/01 -- to be removed after 12 months
import zope.deferredimport
zope.deferredimport.deprecated(
"To get the default browser view of an object, use "
"zope.app.publisher.browser.queryDefaultViewName. To "
"define the default view of an object, use the "
"browser:defaultView directive",
IBrowserDefault = "Products.Five.bbb:IBrowserDefault",
)
##############################################################################
#
# Copyright (c) 2004, 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.
#
##############################################################################
"""Unit tests for the viewable module.
$Id$
"""
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
def test_defaultView():
"""
This tests the default view functionality. It also tests the deprecated
BrowserDefault class. References to BrowserDefault can be removed in 2.12.
Take a class Foo and an interface IFoo:
>>> class Foo:
... pass
>>> from zope.interface import Interface
>>> class IFoo(Interface):
... pass
Set up a default view for IFoo:
>>> from zope.component import provideAdapter
>>> from zope.component.interfaces import IDefaultViewName
>>> from zope.publisher.interfaces.browser import IBrowserRequest
and default view names for everything and IFoo objects in particular:
>>> from Products.Five.bbb import BrowserDefault, IBrowserDefault
>>> from zope.interface import Interface
>>> provideAdapter(BrowserDefault, (Interface,), IBrowserDefault)
>>> provideAdapter(u'index.html', (None, IBrowserRequest), IDefaultViewName)
>>> provideAdapter(u'foo.html', (IFoo, IBrowserRequest), IDefaultViewName)
Now take a BrowserDefault for an instance of Foo::
>>> foo = Foo()
>>> bd = BrowserDefault(foo)
For now the default view name is index.html, like we set above:
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()
>>> from zope.app.publisher.browser import queryDefaultViewName
>>> queryDefaultViewName(foo, request)
u'index.html'
>>> obj, path = bd.defaultView(request)
>>> obj is foo
True
>>> path
[u'index.html']
until we mark the object with IFoo:
>>> from zope.interface import directlyProvides
>>> directlyProvides(foo, IFoo)
>>> queryDefaultViewName(foo, request)
u'foo.html'
>>> obj, path = bd.defaultView(request)
>>> obj is foo
True
>>> path
[u'foo.html']
Clean up adapter registry:
>>> from zope.testing.cleanup import cleanUp
>>> cleanUp()
"""
def test_suite():
import unittest
from zope.testing.doctest import DocTestSuite
from Testing.ZopeTestCase import FunctionalDocFileSuite
return unittest.TestSuite((
DocTestSuite(),
))
if __name__ == '__main__':
framework()
##############################################################################
#
# Copyright (c) 2004, 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.
#
##############################################################################
"""Machinery for making things traversable through adaptation
BBB 2006/05/01 -- to be removed after 12 months
$Id$
"""
import zope.deferredimport
zope.deferredimport.deprecated(
"__bobo_traverse__ and ITraverser/ITraversable for controlling "
"URL traversal have become obsolete. Use an IPublishTraverse "
"adapter instead. This reference will go away in Zope 2.12.",
Traversable = "Products.Five.bbb:Traversable",
FiveTraversable = "zope.traversing.adapters:DefaultTraversable",
)
zope.deferredimport.deprecated(
"Use zope.publisher.browser.TestRequest instead.",
FakeRequest = "zope.publisher.browser:TestRequest",
)
......@@ -4,11 +4,4 @@
<!-- define default namespace adapters, etc. -->
<include package="zope.traversing" />
<!-- BBB 2006/05/01 - to be removed after 12 months -->
<adapter
for="*"
factory=".bbb.BrowserDefault"
provides=".bbb.IBrowserDefault"
/>
</configure>
##############################################################################
#
# Copyright (c) 2004, 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.
#
##############################################################################
"""Machinery for making things viewable
BBB 2006/05/01 -- to be removed after 12 months
$Id$
"""
import zope.deferredimport
zope.deferredimport.deprecated(
"To get the default browser view of an object, use "
"zope.app.publisher.browser.queryDefaultViewName.",
BrowserDefault = "Products.Five.bbb:BrowserDefault",
)
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