[Zope3-checkins] CVS: Zope3/src/zope/i18n - __init__.py:1.5 messageid.py:1.10

Jim Fulton jim at zope.com
Fri Mar 19 07:00:37 EST 2004


Update of /cvs-repository/Zope3/src/zope/i18n
In directory cvs.zope.org:/tmp/cvs-serv3162/src/zope/i18n

Modified Files:
	__init__.py messageid.py 
Log Message:
Factored message ids into a separate package.  At a low level, this
resolves a circular dependency problem between zope.schema and
zope.i18n.  It means that zope.schema doesn't depend on zope.i18n.
This leaves open the question of whether message ids are fundamental
enough that zope.schema (and thus, someday, zope.interface should
depend on them.


=== Zope3/src/zope/i18n/__init__.py 1.4 => 1.5 ===
--- Zope3/src/zope/i18n/__init__.py:1.4	Mon Mar  8 18:35:59 2004
+++ Zope3/src/zope/i18n/__init__.py	Fri Mar 19 07:00:06 2004
@@ -16,7 +16,7 @@
 $Id$
 """
 import re
-from zope.i18n.messageid import MessageIDFactory, MessageID
+from zope.i18nmessageid import MessageIDFactory, MessageID
 from zope.i18n.interfaces import ITranslationDomain
 
 # Set up regular expressions for finding interpolation variables in text.


=== Zope3/src/zope/i18n/messageid.py 1.9 => 1.10 ===
--- Zope3/src/zope/i18n/messageid.py:1.9	Fri Feb 20 04:24:38 2004
+++ Zope3/src/zope/i18n/messageid.py	Fri Mar 19 07:00:07 2004
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2003 Zope Corporation and Contributors.
+# Copyright (c) 2004 Zope Corporation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -11,93 +11,5 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Message IDs.
-
-$Id$
-"""
-
-class MessageID(unicode):
-    """Message ID.
-
-    This is a string used as a message ID.  It has a domain attribute that is
-    its source domain, and a default attribute that is its default text to
-    display when there is no translation.  domain may be None meaning there is
-    no translation domain.  default may also be None, in which case the
-    message id itself implicitly serves as the default text.
-
-    MessageID objects also have a mapping attribute which must be set after
-    construction of the object.  This is used when translating and
-    substituting variables.
-
-    To instanciate MessageIDs, it is recommended to use MessageIDFactory:
-
-    >>> fact = MessageIDFactory('test')
-
-    Now we can use the factory to make MessageIDs. Note that MessageID
-    is a subclass of unicode:
-
-    >>> id = fact(u'this is a test')
-    >>> isinstance(id, MessageID)
-    True
-    >>> isinstance(id, unicode)
-    True
-
-    Additional parameters, such as the i18n domain and the default
-    text are available through attributes:
-
-    >>> id.domain
-    'test'
-    >>> id.default
-    u'this is a test'
-
-    You can also reset the default text:
-
-    >>> id.default = u'blah'
-    >>> id.default
-    u'blah'
-    
-    It is quite common to pass an abstract identifier as message id
-    and then a default text:
-
-    >>> id = fact(u'test-id', 'default test')
-    >>> id
-    u'test-id'
-    >>> id.default
-    u'default test'
-    >>> id.domain
-    'test'
-    """
-
-    __slots__ = ('domain', 'default', 'mapping')
-
-    def __new__(cls, ustr, domain=None, default=None):
-        self = unicode.__new__(cls, ustr)
-        self.domain = domain
-        if default is None:
-            self.default = ustr
-        else:
-            self.default = unicode(default)
-        self.mapping = {}
-        return self
-
-    def __getstate__(self):
-        return unicode(self), self.domain, self.default, self.mapping
-
-    def __setstate__(self, (ustr, domain, default, mapping)):
-        super(MessageID, self).__init__(ustr)
-        self.domain = domain
-        if default is None:
-            self.default = ustr
-        else:
-            self.default = default
-        self.mapping = mapping
-
-
-class MessageIDFactory:
-    """Factory for creating MessageIDs."""
-
-    def __init__(self, domain):
-        self._domain = domain
-
-    def __call__(self, ustr, default=None):
-        return MessageID(ustr, self._domain, default)
+"$Id$"
+from zope.i18nmessageid import MessageID, MessageIDFactory




More information about the Zope3-Checkins mailing list