summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Vasiliev <dima@hlabs.spb.ru>2005-06-17 09:38:51 +0000
committerDmitry Vasiliev <dima@hlabs.spb.ru>2005-06-17 09:38:51 +0000
commit76012879a984717424b326f21af8bceec4794de0 (patch)
tree48f61b62adb696e18c2775a0b118d76c9b66c038
parentbb1972663415263cace20687ec7febf55deeb6d1 (diff)
downloadzope-tal-76012879a984717424b326f21af8bceec4794de0.tar.gz
Added more information for deprecation warning
-rw-r--r--talinterpreter.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/talinterpreter.py b/talinterpreter.py
index 376151e..1946922 100644
--- a/talinterpreter.py
+++ b/talinterpreter.py
@@ -595,12 +595,23 @@ class TALInterpreter(object):
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 @@ class TALInterpreter(object):
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: