[Zope3-checkins] SVN: Zope3/trunk/src/zope/tal/talinterpreter.py Added more information for deprecation warning

Dmitry Vasiliev dima at hlabs.spb.ru
Fri Jun 17 05:38:51 EDT 2005


Log message for revision 30827:
  Added more information for deprecation warning
  

Changed:
  U   Zope3/trunk/src/zope/tal/talinterpreter.py

-=-
Modified: Zope3/trunk/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/talinterpreter.py	2005-06-16 23:48:56 UTC (rev 30826)
+++ Zope3/trunk/src/zope/tal/talinterpreter.py	2005-06-17 09:38:51 UTC (rev 30827)
@@ -595,12 +595,23 @@
         if isinstance(text, I18nMessageTypes):
             # Translate this now.
             # BBB: Deprecated. Will be removed in 3.3
-            warnings.warn('Automatic translation of message id\'s is'
-                ' deprecated and will be removed in 3.3.'
-                ' Use explicit i18n:translate="" instead.', DeprecationWarning)
+            self._i18n_deprecate()
             text = self.engine.translate(text)
         self._writeText(text)
 
+    def _i18n_deprecate(self):
+        if self.sourceFile is None:
+            source = "<unknown>"
+        else:
+            source = self.sourceFile
+        lineno = self.position[0]
+        if lineno is not None:
+            source += " (line %s)" % lineno
+        warnings.warn('%s: Automatic translation of message id\'s is'
+            ' deprecated and will be removed in 3.3.'
+            ' Use explicit i18n:translate="" instead.'
+            % source, DeprecationWarning, 2)
+
     def do_insertI18nText_tal(self, stuff):
         # TODO: Code duplication is BAD, we need to fix it later
         text = self.engine.evaluateText(stuff[0])
@@ -647,10 +658,7 @@
             if isinstance(value, I18nMessageTypes):
                 # Translate this now.
                 # BBB: Deprecated. Will be removed in 3.3
-                warnings.warn('Automatic translation of message id\'s is'
-                    ' deprecated and will be removed in 3.3.'
-                    ' Use explicit i18n:translate="" instead.',
-                    DeprecationWarning)
+                self._i18n_deprecate()
                 value = self.engine.translate(value)
 
             if not structure:



More information about the Zope3-Checkins mailing list