[Zope3-checkins] CVS: Zope3/src/zope/configuration - fields.py:1.8

Jim Fulton jim at zope.com
Mon Aug 4 08:12:12 EDT 2003


Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv14774/src/zope/configuration

Modified Files:
	fields.py 
Log Message:
Changed the MessageID file to record file locations.


=== Zope3/src/zope/configuration/fields.py 1.7 => 1.8 ===
--- Zope3/src/zope/configuration/fields.py:1.7	Sat Aug  2 12:35:58 2003
+++ Zope3/src/zope/configuration/fields.py	Mon Aug  4 07:12:06 2003
@@ -287,7 +287,8 @@
     recorded in the context.
 
     >>> class FauxContext:
-    ...     i18n_strings = {} 
+    ...     i18n_strings = {}
+    ...     info = 'file location'
 
     >>> context = FauxContext()
     >>> field = MessageID().bind(context)
@@ -314,12 +315,16 @@
     In addition, the string has been registered with the context:
 
     >>> context.i18n_strings
-    {'testing': {u'Hello world!': 1}}
+    {'testing': {u'Hello world!': ["'file location'"]}}
 
     >>> i = field.fromUnicode(u"Foo Bar")
     >>> i = field.fromUnicode(u"Hello world!")
-    >>> context.i18n_strings
-    {'testing': {u'Foo Bar': 1, u'Hello world!': 1}}
+    >>> from pprint import PrettyPrinter
+    >>> pprint=PrettyPrinter(width=70).pprint
+    >>> pprint(context.i18n_strings)
+    {'testing': {u'Foo Bar': ["'file location'"],
+                 u'Hello world!': ["'file location'",
+                                   "'file location'"]}}
     """
 
     implements(IFromUnicode)
@@ -327,18 +332,20 @@
     __factories = {}
 
     def fromUnicode(self, u):
-        domain = getattr(self.context, 'i18n_domain', '')
+        context = self.context
+        domain = getattr(context, 'i18n_domain', '')
         if not domain:
             raise ConfigurationError(
                 "You must specify a an i18n translation domain")
         v = super(MessageID, self).fromUnicode(u)
 
         # Record the string we got for the domain
-        i18n_strings = self.context.i18n_strings
+        i18n_strings = context.i18n_strings
         strings = i18n_strings.get(domain)
         if strings is None:
             strings = i18n_strings[domain] = {}
-        strings[v] = 1
+        locations = strings.setdefault(v, [])
+        locations.append(`context.info`)
 
         # Convert to a message id, importing the factory, if necessary
         factory = self.__factories.get(domain)




More information about the Zope3-Checkins mailing list