[Zope3-checkins] SVN: Zope3/trunk/src/z Changed the specification
for publishTraverse to raise NotFound
Jim Fulton
jim at zope.com
Tue Oct 26 18:22:38 EDT 2004
Log message for revision 28261:
Changed the specification for publishTraverse to raise NotFound
Previously, the interface was silent (lazy) on what happened when an
object could not be traversed.
Updated various bits of code to reflect this.
Changed:
U Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py
U Zope3/trunk/src/zope/app/http/tests/test_traversers.py
U Zope3/trunk/src/zope/app/http/traversal.py
U Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
U Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py
U Zope3/trunk/src/zope/app/publisher/browser/fileresource.py
U Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py
U Zope3/trunk/src/zope/app/publisher/browser/resources.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_fileresource.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/testi18nfileresource.py
U Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
U Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py
U Zope3/trunk/src/zope/app/schema/browser/traversal.py
U Zope3/trunk/src/zope/publisher/interfaces/__init__.py
U Zope3/trunk/src/zwiki/tests/test_traverser.py
U Zope3/trunk/src/zwiki/traversal.py
-=-
Modified: Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/container/tests/test_containertraverser.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -21,7 +21,7 @@
from zope.app.tests import ztapi
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.component.tests.request import Request
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserRequest
@@ -69,7 +69,7 @@
self.traverser.publishTraverse(self.request, 'Foo'),
self.foo)
self.assertRaises(
- NotFoundError,
+ NotFound,
self.traverser.publishTraverse, self.request, 'morebar')
def test_viewTraversal(self):
@@ -80,10 +80,10 @@
self.traverser.publishTraverse(self.request, 'Foo'),
self.foo)
self.assertRaises(
- NotFoundError,
+ NotFound,
self.traverser.publishTraverse, self.request, 'morebar')
self.assertRaises(
- NotFoundError,
+ NotFound,
self.traverser.publishTraverse, self.request, '@@morebar')
Modified: Zope3/trunk/src/zope/app/http/tests/test_traversers.py
===================================================================
--- Zope3/trunk/src/zope/app/http/tests/test_traversers.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/http/tests/test_traversers.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -16,7 +16,7 @@
$Id$
"""
from unittest import TestCase, TestSuite, main, makeSuite
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.app.http.traversal import ContainerTraverser, ItemTraverser
from zope.publisher.browser import TestRequest
from zope.app.http.put import NullResource
@@ -50,7 +50,7 @@
container = self.Container({'foo': 42})
request = TestRequest()
traverser = self.Traverser(container, request)
- self.assertRaises(NotFoundError,
+ self.assertRaises(NotFound,
traverser.publishTraverse, request, 'bar')
Modified: Zope3/trunk/src/zope/app/http/traversal.py
===================================================================
--- Zope3/trunk/src/zope/app/http/traversal.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/http/traversal.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -21,7 +21,7 @@
from zope.publisher.interfaces.http import IHTTPPublisher
from zope.app.container.interfaces import ISimpleReadContainer, IItemContainer
from zope.app.http.put import NullResource
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.interface import implements
class ContainerTraverser(object):
@@ -45,11 +45,11 @@
# The name must be the last name in the path, so the traversal
# name stack better be empty:
if request.getTraversalStack():
- raise NotFoundError(self.context, name, request)
+ raise NotFound(self.context, name, request)
# This should only happen for a PUT or MKCOL:
if request.method not in ['PUT', 'MKCOL']:
- raise NotFoundError(self.context, name, request)
+ raise NotFound(self.context, name, request)
return NullResource(self.context, name)
Modified: Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -17,7 +17,7 @@
"""
import unittest
from zope.component.tests.request import Request
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.interface import Interface
from zope.app.publication.traversers import SimpleComponentTraverser
@@ -56,7 +56,7 @@
T = SimpleComponentTraverser(c, req)
- self.assertRaises(NotFoundError , T.publishTraverse, req ,'foo')
+ self.assertRaises(NotFound , T.publishTraverse, req ,'foo')
def testView(self):
@@ -70,7 +70,7 @@
self.failUnless(T.publishTraverse(req,'foo').__class__ is View)
- self.assertRaises(NotFoundError, T.publishTraverse, req , 'morebar')
+ self.assertRaises(NotFound, T.publishTraverse, req , 'morebar')
Modified: Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -27,7 +27,7 @@
import posixpath
from zope.interface import implements
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.security.proxy import Proxy
from zope.app.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
@@ -82,7 +82,7 @@
filename = os.path.join(path, name)
if not os.path.isfile(filename):
if default is _marker:
- raise NotFoundError(name)
+ raise NotFound(None, name)
return default
ext = os.path.splitext(os.path.normcase(name))[1]
factory = self.resource_factories.get(ext, self.default_factory)
Modified: Zope3/trunk/src/zope/app/publisher/browser/fileresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/fileresource.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/fileresource.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -15,7 +15,7 @@
$Id$
"""
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.app.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
@@ -34,7 +34,7 @@
def publishTraverse(self, request, name):
'''See interface IBrowserPublisher'''
- raise NotFoundError(name)
+ raise NotFound(None, name)
def browserDefault(self, request):
'''See interface IBrowserPublisher'''
Modified: Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -17,7 +17,7 @@
"""
from zope.interface import implements
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.security.proxy import Proxy
from zope.app.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
@@ -31,7 +31,7 @@
def publishTraverse(self, request, name):
'''See interface IBrowserPublisher'''
- raise NotFoundError(name)
+ raise NotFound(None, name)
def browserDefault(self, request):
'''See interface IBrowserPublisher'''
Modified: Zope3/trunk/src/zope/app/publisher/browser/resources.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/resources.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/resources.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -17,7 +17,7 @@
"""
from zope.app.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.interface import implements
from zope.app import zapi
@@ -34,7 +34,7 @@
resource = zapi.queryResource(name, request)
if resource is None:
- raise NotFoundError(self, name)
+ raise NotFound(self, name)
adapters = zapi.getService(zapi.servicenames.Adapters)
locate(resource, adapters, name)
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directoryresource.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -18,7 +18,7 @@
import os
from unittest import TestCase, main, makeSuite
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.proxy import isProxy
from zope.security.proxy import removeSecurityProxy
from zope.publisher.browser import TestRequest
@@ -53,9 +53,9 @@
request = TestRequest()
factory = DirectoryResourceFactory(path, checker, 'testfiles')
resource = factory(request)
- self.assertRaises(NotFoundError, resource.publishTraverse,
+ self.assertRaises(NotFound, resource.publishTraverse,
resource.request, 'doesnotexist')
- self.assertRaises(NotFoundError, resource.get, 'doesnotexist')
+ self.assertRaises(NotFound, resource.get, 'doesnotexist')
def testGetitem(self):
path = os.path.join(test_directory, 'testfiles')
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_fileresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_fileresource.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_fileresource.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -18,7 +18,7 @@
import os
from unittest import TestCase, main, makeSuite
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.i18n.interfaces import IUserPreferredCharsets
from zope.security.proxy import removeSecurityProxy
from zope.security.checker import NamesChecker
@@ -52,7 +52,7 @@
path = os.path.join(test_directory, 'testfiles', 'test.txt')
factory = FileResourceFactory(path, checker, 'test.txt')
resource = factory(TestRequest())
- self.assertRaises(NotFoundError,
+ self.assertRaises(NotFound,
resource.publishTraverse,
resource.request,
'_testData')
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -18,7 +18,7 @@
import os
from unittest import TestCase, main, makeSuite
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.app.tests import ztapi
from zope.security.checker import NamesChecker
from zope.publisher.browser import TestRequest
@@ -47,7 +47,7 @@
request = TestRequest()
factory = PageTemplateResourceFactory(path, checker, 'test.pt')
resource = factory(request)
- self.assertRaises(NotFoundError, resource.publishTraverse,
+ self.assertRaises(NotFound, resource.publishTraverse,
resource.request, ())
def testCall(self):
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -62,10 +62,10 @@
def testNotFound(self):
from zope.app.publisher.browser.resources import Resources
- from zope.exceptions import NotFoundError
+ from zope.publisher.interfaces import NotFound
request = TestRequest()
view = Resources(None, request)
- self.assertRaises(NotFoundError,
+ self.assertRaises(NotFound,
view.publishTraverse,
request, 'test'
)
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/testi18nfileresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/testi18nfileresource.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/testi18nfileresource.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -18,7 +18,7 @@
from unittest import main, makeSuite
import os
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.app.tests import ztapi
@@ -73,7 +73,7 @@
resource = I18nFileResourceFactory(self._createDict(), 'en')\
(TestRequest())
- self.assertRaises(NotFoundError,
+ self.assertRaises(NotFound,
resource.publishTraverse,
resource.request,
'_testData')
Modified: Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -20,7 +20,7 @@
from zope.component.exceptions import ComponentLookupError
from zope.component.interfaces import IDefaultViewName
from zope.interface import implements, classImplements, Interface
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.security.checker import CheckerPublic, Checker
from zope.security.checker import defineChecker
from zope.configuration.exceptions import ConfigurationError
@@ -290,7 +290,7 @@
if view is not None:
return view
- raise NotFoundError(self, name, request)
+ raise NotFound(self, name, request)
cdict['publishTraverse'] = publishTraverse
@@ -434,7 +434,7 @@
implements(IBrowserPublisher)
def publishTraverse(self, request, name):
- raise NotFoundError(self, name, request)
+ raise NotFound(self, name, request)
def __call__(self, *a, **k):
# If a class doesn't provide it's own call, then get the attribute
Modified: Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -21,6 +21,7 @@
from zope.pagetemplate.tests.util import check_xml
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.publisher.interfaces import NotFound
from zope.app.tests import ztapi
from zope.app.traversing.api import traverse
@@ -65,7 +66,7 @@
def browserDefault(self, request):
return self, ()
def publishTraverse(self, request, name):
- raise NotFoundError(self, name, request)
+ raise NotFound(self, name, request)
def __call__(self):
return self.singleBranchTree()
Modified: Zope3/trunk/src/zope/app/schema/browser/traversal.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/browser/traversal.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/app/schema/browser/traversal.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -19,6 +19,7 @@
from zope.app.schema.interfaces import IMutableSchema
from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.app.traversing.interfaces import ITraversable
from zope.app.traversing.namespace import UnexpectedParameters
@@ -47,7 +48,7 @@
return view
- raise NotFoundError(self.context, name, request)
+ raise NotFound(self.context, name, request)
return subob
Modified: Zope3/trunk/src/zope/publisher/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -159,6 +159,8 @@
"""Lookup a name
The request argument is the publisher request object.
+
+ If a lookup is not possible, raise a NotFound error.
"""
Modified: Zope3/trunk/src/zwiki/tests/test_traverser.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_traverser.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zwiki/tests/test_traverser.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -19,7 +19,7 @@
from zope.component.tests.request import Request
from zope.interface import Interface, classImplements
-from zope.exceptions import NotFoundError
+from zope.publisher.interfaces import NotFound
from zope.proxy import removeAllProxies
from zope.app import zapi
@@ -72,7 +72,7 @@
self.failUnless(
removeAllProxies(T.publishTraverse(request, 'FooBar')) is page2)
- self.assertRaises(NotFoundError, T.publishTraverse, request,'morebar')
+ self.assertRaises(NotFound, T.publishTraverse, request,'morebar')
def testView(self):
wiki = Wiki()
@@ -91,8 +91,8 @@
self.failUnless(
removeAllProxies(T.publishTraverse(request, 'FooBar')) is page2)
- self.assertRaises(NotFoundError, T.publishTraverse, request, 'morebar')
- self.assertRaises(NotFoundError, T.publishTraverse, request,
+ self.assertRaises(NotFound, T.publishTraverse, request, 'morebar')
+ self.assertRaises(NotFound, T.publishTraverse, request,
'@@morebar')
Modified: Zope3/trunk/src/zwiki/traversal.py
===================================================================
--- Zope3/trunk/src/zwiki/traversal.py 2004-10-26 21:45:25 UTC (rev 28260)
+++ Zope3/trunk/src/zwiki/traversal.py 2004-10-26 22:22:37 UTC (rev 28261)
@@ -17,6 +17,7 @@
from zope.proxy import removeAllProxies
from zope.component import getDefaultViewName, queryView
from zope.publisher.interfaces import IPublishTraverse
+from zope.publisher.interfaces import NotFound
from zope.exceptions import NotFoundError
from zope.app import zapi
@@ -46,7 +47,7 @@
if view is not None:
return view
- raise NotFoundError(self.context, name, request)
+ raise NotFound(self.context, name, request)
return removeAllProxies(page)
More information about the Zope3-Checkins
mailing list