[Zope3-checkins] SVN: Zope3/trunk/ #284: Deprecation of
NotFoundError
Julien Anguenot
ja at nuxeo.com
Thu Jul 28 10:02:50 EDT 2005
Log message for revision 37531:
#284: Deprecation of NotFoundError
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/doc/TODO.txt
U Zope3/trunk/src/zope/app/copypastemove/__init__.py
U Zope3/trunk/src/zope/app/copypastemove/interfaces.py
U Zope3/trunk/src/zope/app/fssync/fsregistry.py
U Zope3/trunk/src/zope/app/fssync/interfaces.py
U Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py
U Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py
U Zope3/trunk/src/zope/app/http/exception/configure.zcml
U Zope3/trunk/src/zope/app/security/interfaces.py
U Zope3/trunk/src/zope/app/security/principal.py
U Zope3/trunk/src/zope/app/security/vocabulary.py
U Zope3/trunk/src/zope/app/traversing/adapters.py
U Zope3/trunk/src/zope/app/traversing/api.py
U Zope3/trunk/src/zope/app/traversing/interfaces.py
U Zope3/trunk/src/zope/app/traversing/namespace.py
U Zope3/trunk/src/zope/app/undo/__init__.py
U Zope3/trunk/src/zope/component/interfaces.py
U Zope3/trunk/src/zope/exceptions/__init__.py
U Zope3/trunk/src/zope/exceptions/_notfounderror.py
U Zope3/trunk/src/zope/publisher/interfaces/__init__.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/doc/CHANGES.txt 2005-07-28 14:02:49 UTC (rev 37531)
@@ -655,6 +655,8 @@
Bug Fixes
+ - Fix #284: Bogus 404 errors with TALES traversal fails
+
- Fix #298: Role/permission title and description should be messageids
- Fix #332 : Death to IContentContainer
@@ -850,7 +852,8 @@
Jim Fulton, Fred Drake, Philipp von Weitershausen, Stephan Richter,
Gustavo Niemeyer, Daniel Nouri, Volker Bachschneider, Roger Ineichen,
Shane Hathaway, Bjorn Tillenius, Garrett Smith, Marius Gedminas, Stuart
- Bishop, Dominik Huber, Dmitry Vasiliev, Gary Poster, Brian Lloyd
+ Bishop, Dominik Huber, Dmitry Vasiliev, Gary Poster, Brian Lloyd,
+ Julien Anguenot
------------------------------------------------------------------
Modified: Zope3/trunk/doc/TODO.txt
===================================================================
--- Zope3/trunk/doc/TODO.txt 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/doc/TODO.txt 2005-07-28 14:02:49 UTC (rev 37531)
@@ -23,8 +23,6 @@
Others
~~~~~~
- * 284: Bogus 404 errors with TALES traversal fails
-
* 296: missing display widgets
* 316: Zope3 test.py truncates path with dir=
Modified: Zope3/trunk/src/zope/app/copypastemove/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/copypastemove/__init__.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/copypastemove/__init__.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -17,8 +17,10 @@
"""
__docformat__ = 'restructuredtext'
+import zope.deprecation
+
from zope.interface import implements, Invalid
-from zope.exceptions import NotFoundError, DuplicationError
+from zope.exceptions import DuplicationError
from zope.component import adapts
from zope.event import notify
@@ -38,9 +40,18 @@
from zope.app.copypastemove.interfaces import IObjectCopier
from zope.app.copypastemove.interfaces import IContainerItemRenamer
from zope.app.copypastemove.interfaces import IPrincipalClipboard
+from zope.app.copypastemove.interfaces import IItemNotFoundError
+# BBB (remove in 3.3)
+zope.deprecation.__show__.off()
+from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
+
import warnings # BBB (remove in 3.3)
+class ItemNotFoundError(NotFoundError):
+ implements(IItemNotFoundError)
+
class ObjectMover(object):
"""Adapter for moving objects between containers
@@ -474,7 +485,7 @@
>>> renamer.renameItem('foo', 'bar') # doctest:+ELLIPSIS
Traceback (most recent call last):
- NotFoundError: (<...SampleContainer...>, 'foo')
+ ItemNotFoundError: (<...SampleContainer...>, 'foo')
If the new item name already exists, a DuplicationError is raised:
@@ -494,7 +505,7 @@
def renameItem(self, oldName, newName):
object = self.container.get(oldName)
if object is None:
- raise NotFoundError(self.container, oldName)
+ raise ItemNotFoundError(self.container, oldName)
mover = IObjectMover(object)
if newName in self.container:
@@ -551,7 +562,7 @@
>>> renamer.renameItem('IV', '4') # doctest:+ELLIPSIS
Traceback (most recent call last):
- NotFoundError: (<...OrderedContainer...>, 'IV')
+ ItemNotFoundError: (<...OrderedContainer...>, 'IV')
And if the new item name already exists, a DuplicationError is raised:
Modified: Zope3/trunk/src/zope/app/copypastemove/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/copypastemove/interfaces.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/copypastemove/interfaces.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -66,7 +66,7 @@
def renameItem(oldName, newName):
"""Renames an object in the container from oldName to newName.
- Raises NotFoundError if oldName doesn't exist in the container.
+ Raises KeyError if oldName doesn't exist in the container.
Raises DuplicationError if newName is already used in the container.
"""
@@ -90,3 +90,6 @@
def getContents():
"""Return the contents of the clipboard"""
+
+class IItemNotFoundError(Interface):
+ pass
Modified: Zope3/trunk/src/zope/app/fssync/fsregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/fsregistry.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/fssync/fsregistry.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -19,10 +19,23 @@
"""
__docformat__ = 'restructuredtext'
-from zope.exceptions import DuplicationError, NotFoundError
+import zope.deprecation
+
+from zope.exceptions import DuplicationError
from zope.interface import implements
from zope.app.fssync.interfaces import IGlobalFSSyncUtility
+from zope.app.fssync.interfaces import IFactoryNotFoundError
+# BBB Backward Compatibility (Can go away in 3.3)
+zope.deprecation.__show__.off()
+from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
+
+class FactoryNotFoundError(NotFoundError):
+ # BBB : NotFoundError inheritance
+ # Backward Compatibility (Can go away in 3.3)
+ implements(IFactoryNotFoundError)
+
class FSRegistry(object):
"""Registry Wrapper class.
@@ -42,17 +55,16 @@
If no factory is registered for the given class, return the
default factory, if one has been registered. If no default
- factory has been registered, raise ``NotFoundError``.
+ factory has been registered, raise ``FactoryNotFoundError``.
"""
factory = self._class_factory_reg.get(object.__class__)
if factory is None:
factory = self._class_factory_reg.get(None)
if factory is None:
- raise NotFoundError
+ raise FactoryNotFoundError
return factory(object)
-
def provideSynchronizer(self,class_, factory):
"""Set `class_`, factory into the dictionary."""
if class_ in self._class_factory_reg:
Modified: Zope3/trunk/src/zope/app/fssync/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/interfaces.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/fssync/interfaces.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -19,6 +19,8 @@
from zope.interface import Interface
+class IFactoryNotFoundError(Interface):
+ pass
class IFSSyncUtility(Interface):
"""Lookup file-system representation adapters."""
Modified: Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_fsdirective.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -17,13 +17,13 @@
"""
import unittest
+from zope.app.fssync.fsregistry import FactoryNotFoundError
from zope.app.fssync.fsregistry import getSynchronizer
from zope.app.fssync.tests.sampleclass import \
C1, C2, CDirAdapter, CDefaultAdapter
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.configuration import xmlconfig
from zope.configuration.config import ConfigurationConflictError
-from zope.exceptions import NotFoundError
import zope.app.fssync.tests
@@ -31,7 +31,7 @@
def testFSDirective(self):
# Register the adapter for the class
- self.assertRaises(NotFoundError, getSynchronizer, C2())
+ self.assertRaises(FactoryNotFoundError, getSynchronizer, C2())
self.context = xmlconfig.file("fssync.zcml", zope.app.fssync.tests)
self.assertEqual(getSynchronizer(C2()).__class__, CDirAdapter)
Modified: Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_fsregistry.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -20,13 +20,17 @@
from zope.testing.cleanup import CleanUp
from zope.interface.verify import verifyObject
-from zope.exceptions import DuplicationError, NotFoundError
+from zope.exceptions import DuplicationError
from zope.app.fssync.interfaces import IGlobalFSSyncUtility
+
+from zope.app.fssync.fsregistry import getSynchronizer
+from zope.app.fssync.fsregistry import provideSynchronizer
+from zope.app.fssync.fsregistry import fsRegistry
+from zope.app.fssync.fsregistry import FactoryNotFoundError
+
from zope.app.fssync.tests.sampleclass \
import C1, C2, CDirAdapter, CFileAdapter, CDefaultAdapter
-from zope.app.fssync.fsregistry \
- import getSynchronizer, provideSynchronizer, fsRegistry
class Test(CleanUp, TestCase):
"""Test Interface for FSRegistry Instance.
@@ -39,7 +43,7 @@
""" Test Class and Factory registration and getSynchronizer to get
appropriate factory for that class.
"""
- self.assertRaises(NotFoundError, getSynchronizer, C1())
+ self.assertRaises(FactoryNotFoundError, getSynchronizer, C1())
provideSynchronizer(C1, CFileAdapter)
cl = C1()
Modified: Zope3/trunk/src/zope/app/http/exception/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/http/exception/configure.zcml 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/http/exception/configure.zcml 2005-07-28 14:02:49 UTC (rev 37531)
@@ -15,6 +15,21 @@
/>
<view
+ for="zope.publisher.interfaces.ITraversalException"
+ type="zope.publisher.interfaces.http.IHTTPRequest"
+ name="index.html"
+ permission="zope.Public"
+ factory=".notfound.NotFound"
+ />
+
+<defaultView
+ for="zope.publisher.interfaces.ITraversalException"
+ type="zope.publisher.interfaces.http.IHTTPRequest"
+ name="index.html"
+ />
+
+<!-- BBB : can be removed in 3.3 -->
+<view
for="zope.exceptions.INotFoundError"
type="zope.publisher.interfaces.http.IHTTPRequest"
name="index.html"
@@ -27,6 +42,7 @@
type="zope.publisher.interfaces.http.IHTTPRequest"
name="index.html"
/>
+<!-- END BBB : can be removed in 3.3 -->
<view
for="zope.app.publication.http.IMethodNotAllowed"
Modified: Zope3/trunk/src/zope/app/security/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/security/interfaces.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/security/interfaces.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -15,13 +15,19 @@
$Id$
"""
+
+import zope.deprecation
+
from zope.interface import Interface
from zope.app.i18n import ZopeMessageIDFactory as _
from zope.schema import Text, TextLine
from zope.security.interfaces import IPrincipal, IPermission, IGroup
from zope.schema.interfaces import ISource
+# BBB : Can move away in 3.3
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
class PrincipalLookupError(NotFoundError):
"""A prncipal could not be found for a principal id
Modified: Zope3/trunk/src/zope/app/security/principal.py
===================================================================
--- Zope3/trunk/src/zope/app/security/principal.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/security/principal.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -15,12 +15,18 @@
$Id$
"""
+
+import zope.deprecation
+
from zope.app import zapi
from zope.app.security.interfaces import PrincipalLookupError
from zope.app.security.interfaces import IAuthentication
-# BBB Backward Compatibility
+# BBB Backward Compatibility (Can go away in 3.3)
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
+
import warnings
def checkPrincipal(context, principal_id):
Modified: Zope3/trunk/src/zope/app/security/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/security/vocabulary.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/security/vocabulary.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -17,6 +17,8 @@
$Id$
"""
+import zope.deprecation
+
from zope.security.checker import CheckerPublic
from zope.app import zapi
from zope.interface import implements
@@ -27,7 +29,10 @@
from zope.app.component import queryNextUtility
# BBB Backward Compatibility
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
+
import warnings
from interfaces import IPrincipalSource
Modified: Zope3/trunk/src/zope/app/traversing/adapters.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/adapters.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/traversing/adapters.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -15,6 +15,8 @@
$Id$
"""
+import zope.deprecation
+
from types import StringTypes, MethodType
from zope.app.traversing.interfaces import TraversalError
@@ -29,7 +31,10 @@
from zope.app.traversing.namespace import nsParse
# BBB Backward Compatibility (Can go away in 3.3)
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
+
import warnings
_marker = object() # opaque marker that doesn't get security proxied
Modified: Zope3/trunk/src/zope/app/traversing/api.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/api.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/traversing/api.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -15,13 +15,17 @@
$Id$
"""
+import zope.deprecation
from zope.interface import moduleProvides
from interfaces import IContainmentRoot, ITraversalAPI
from interfaces import ITraverser, IPhysicallyLocatable, TraversalError
# BBB Backward Compatibility (Can go away in 3.3)
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
+
import warnings
moduleProvides(ITraversalAPI)
Modified: Zope3/trunk/src/zope/app/traversing/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/interfaces.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/traversing/interfaces.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -17,9 +17,7 @@
"""
from zope.interface import Interface
-from zope.exceptions import NotFoundError
-
-class TraversalError(NotFoundError):
+class TraversalError(KeyError, LookupError):
"""There is no object for the name given to a traversal
"""
@@ -34,7 +32,7 @@
The name lookup usually depends on an object and/or a
request. If an object or request is unavailable, None will be passed.
-
+
The parameters provided, are passed as a sequence of
name, value items. The 'pname' argument has the original name
before parameters were removed.
Modified: Zope3/trunk/src/zope/app/traversing/namespace.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/namespace.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/traversing/namespace.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -17,6 +17,7 @@
"""
import re
+import zope.deprecation
import zope.component
import zope.interface
from zope.component.exceptions import ComponentLookupError
@@ -28,8 +29,11 @@
from zope.app.traversing.interfaces import ITraversable, IPathAdapter
from zope.app.traversing.interfaces import TraversalError
-# BBB Backward Compatibility
+# BBB Backward Compatibility (Can go away in 3.3)
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
+
import warnings
class UnexpectedParameters(TraversalError):
Modified: Zope3/trunk/src/zope/app/undo/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/undo/__init__.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/app/undo/__init__.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -19,6 +19,7 @@
import transaction
+import zope.deprecation
from zope.interface import implements
from zope.app.security.interfaces import PrincipalLookupError
@@ -28,8 +29,10 @@
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.interfaces import IPrincipal
-# BBB Backward Compatibility
+# BBB Backward Compatibility (Can go away in 3.3)
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
import warnings
def undoSetup(event):
Modified: Zope3/trunk/src/zope/component/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/component/interfaces.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/component/interfaces.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -15,13 +15,18 @@
$Id$
"""
+import zope.deprecation
+
from zope.interface import Interface, Attribute
+
+# BBB: Can be removed in 3.3
+zope.deprecation.__show__.off()
from zope.exceptions import NotFoundError
+zope.deprecation.__show__.on()
# BBB: Backward-compatibility; 12/05/2004
from bbb.interfaces import *
-
class ComponentLookupError(NotFoundError):
"""A component could not be found."""
@@ -31,7 +36,6 @@
class Misused(Exception):
"""A component is being used (registered) for the wrong interface."""
-
class IComponentArchitecture(Interface, IBBBComponentArchitecture):
"""The Component Architecture is defined by two key components: Adapters
and Utiltities. Both are managed by site managers. All other components
Modified: Zope3/trunk/src/zope/exceptions/__init__.py
===================================================================
--- Zope3/trunk/src/zope/exceptions/__init__.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/exceptions/__init__.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -19,7 +19,24 @@
$Id$
"""
+import zope.deprecation
+
+zope.deprecation.deprecated('INotFoundError',
+ 'This interface has been deprecated. '
+ 'Use standard interface instead '
+ 'The reference will be gone in 3.3')
+
+zope.deprecation.deprecated('NotFoundError',
+ 'This class has been deprecated. '
+ 'Use standard exceptions instead '
+ 'The reference will be gone in 3.3')
+
+# Turn of deprecation warning here for the above import that are here for BBB
+# The depreaction above and within the _notfounderror module will do the job.
+zope.deprecation.__show__.off()
from zope.exceptions._notfounderror import NotFoundError, INotFoundError
+zope.deprecation.__show__.on()
+
from zope.exceptions._duplicate import DuplicationError, IDuplicationError
# Importing these interfaces from here is deprecated!
Modified: Zope3/trunk/src/zope/exceptions/_notfounderror.py
===================================================================
--- Zope3/trunk/src/zope/exceptions/_notfounderror.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/exceptions/_notfounderror.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -15,9 +15,22 @@
$Id$
"""
+
+from zope.deprecation import deprecated
+
from zope.interface.common.interfaces import IKeyError
from zope.interface import implements
+deprecated('INotFoundError',
+ 'This interface has been deprecated. '
+ 'Use standard interface instead '
+ 'The reference will be gone in 3.3')
+
+deprecated('NotFoundError',
+ 'This class has been deprecated. '
+ 'Use standard exceptions instead '
+ 'The reference will be gone in 3.3')
+
class INotFoundError(IKeyError):
pass
Modified: Zope3/trunk/src/zope/publisher/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2005-07-28 10:14:13 UTC (rev 37530)
+++ Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2005-07-28 14:02:49 UTC (rev 37531)
@@ -16,10 +16,11 @@
$Id$
"""
+import zope.deprecation
+
from zope.interface import Interface
from zope.interface import Attribute
from zope.security.interfaces import Unauthorized
-from zope.exceptions import NotFoundError, INotFoundError
from zope.component.interfaces import IPresentationRequest
from zope.interface import implements
from zope.interface.interfaces import IInterface
@@ -27,6 +28,11 @@
from zope.interface.common.interfaces import IException
from zope.security.interfaces import IParticipation
+# BBB : can be remove in 3.3
+zope.deprecation.__show__.off()
+from zope.exceptions import NotFoundError, INotFoundError
+zope.deprecation.__show__.on()
+
class IPublishingException(IException):
pass
More information about the Zope3-Checkins
mailing list