[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/exceptions/ Merged from branch:

Jim Fulton jim at zope.com
Thu Jul 8 15:38:37 EDT 2004


Log message for revision 26222:
Merged from branch:

r26171 | jim | 2004-07-07 13:42:50 -0400 (Wed, 07 Jul 2004) | 4 lines
(also r26162, but that's not important)

Removed dependency on i18n.  zope.exceptions shouldn't be trying to set
the domain of strings padded to Unauthorized.  It turns out that in 
all cases that mattered, the strings passed were ignored.




-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/exceptions/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/exceptions/__init__.py	2004-07-08 19:22:55 UTC (rev 26221)
+++ Zope3/branches/ZopeX3-3.0/src/zope/exceptions/__init__.py	2004-07-08 19:38:37 UTC (rev 26222)
@@ -18,14 +18,6 @@
 
 $Id$
 """
-# This module should be independent of I18n, so let's not require it.
-try:
-    from zope.i18n import MessageIDFactory
-except ImportError:
-    ZopeMessageIDFactory = unicode
-else:
-    # Import _ to use to create message ids in the zope domain
-    ZopeMessageIDFactory = MessageIDFactory('zope')
 
 from zope.exceptions._zope_error import ZopeError, IZopeError
 from zope.exceptions.unauthorized import Unauthorized, IUnauthorized

Modified: Zope3/branches/ZopeX3-3.0/src/zope/exceptions/unauthorized.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/exceptions/unauthorized.py	2004-07-08 19:22:55 UTC (rev 26221)
+++ Zope3/branches/ZopeX3-3.0/src/zope/exceptions/unauthorized.py	2004-07-08 19:38:37 UTC (rev 26222)
@@ -15,13 +15,10 @@
 
 $Id$
 """
-from types import StringType
 from zope.exceptions import ZopeError
 from zope.exceptions import IZopeError
-from zope.exceptions import ZopeMessageIDFactory as _
 from zope.interface import implements
 
-
 class IUnauthorized(IZopeError):
     pass
 
@@ -29,57 +26,3 @@
     """Some user wasn't allowed to access a resource"""
 
     implements(IUnauthorized)
-
-    def __init__(self, message=None, value=None, needed=None, name=None, **kw):
-        """Possible signatures:
-
-        Unauthorized()
-        Unauthorized(message) # Note that message includes a space
-        Unauthorized(name)
-        Unauthorized(name, value)
-        Unauthorized(name, value, needed)
-        Unauthorized(message, value, needed, name)
-
-        Where needed is a mapping objects with items represnting requirements
-        (e.g. {'permission': 'add spam'}). Any extra keyword arguments
-        provides are added to needed.
-        """
-        if name is None and (
-            not isinstance(message, StringType) or len(message.split()) <= 1):
-            # First arg is a name, not a message
-            name = message
-            message = None
-
-        self.name = name
-        self.message = message
-        self.value = value
-
-        if kw:
-            if needed:
-                needed.update(kw)
-            else:
-                needed = kw
-
-        self.needed = needed
-
-    def __str__(self):
-        if self.message is not None:
-            return _(self.message)
-        if self.name is not None:
-            msg = _("You are not allowed to access ${name} in this context")
-            msg.mapping = {'name': self.name}
-        elif self.value is not None:
-            msg = _("You are not allowed to access ${name} in this context")
-            msg.mapping = {'name': self.getValueName()}
-        return _("You are not authorized")
-
-
-    def getValueName(self):
-        v = self.value
-        vname = getattr(v, '__name__', None)
-        if vname:
-            return vname
-        c = getattr(v, '__class__', type(v))
-        c = getattr(c, '__name__', 'object')
-        msg = _("a particular ${object}")
-        msg.mapping = {'object': c}



More information about the Zope3-Checkins mailing list