[Zope3-checkins] CVS: Zope3/src/zope/exceptions - __init__.py:1.5
unauthorized.py:1.9
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Aug 12 16:15:24 EDT 2003
Update of /cvs-repository/Zope3/src/zope/exceptions
In directory cvs.zope.org:/tmp/cvs-serv15705/exceptions
Modified Files:
__init__.py unauthorized.py
Log Message:
Internationalized Exception Views
=== Zope3/src/zope/exceptions/__init__.py 1.4 => 1.5 ===
--- Zope3/src/zope/exceptions/__init__.py:1.4 Tue Feb 11 11:00:06 2003
+++ Zope3/src/zope/exceptions/__init__.py Tue Aug 12 15:14:50 2003
@@ -18,6 +18,14 @@
$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
=== Zope3/src/zope/exceptions/unauthorized.py 1.8 => 1.9 ===
--- Zope3/src/zope/exceptions/unauthorized.py:1.8 Mon Jun 30 13:10:18 2003
+++ Zope3/src/zope/exceptions/unauthorized.py Tue Aug 12 15:14:50 2003
@@ -11,15 +11,17 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Unauthorized Exception definition
+
$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
@@ -62,14 +64,14 @@
def __str__(self):
if self.message is not None:
- return self.message
+ return _(self.message)
if self.name is not None:
- return ("You are not allowed to access %s in this context"
- % self.name)
+ msg = _("You are not allowed to access ${name} in this context")
+ msg.mapping = {'name': self.name}
elif self.value is not None:
- return ("You are not allowed to access %s in this context"
- % self.getValueName())
- return "You are not authorized"
+ msg = _("You are not allowed to access ${name} in this context")
+ msg.mapping = {'name': self.getValueName()}
+ return _("You are not authorized")
def getValueName(self):
@@ -79,5 +81,5 @@
return vname
c = getattr(v, '__class__', type(v))
c = getattr(c, '__name__', 'object')
- return "a particular %s" % c
-
+ msg = _("a particular ${object}")
+ msg.mapping = {'object': c}
More information about the Zope3-Checkins
mailing list