validators optionally require globals

This commit is contained in:
Massimo DiPierro
2012-03-12 22:34:52 -05:00
parent 9df9b5c4ee
commit f556c9cd8d
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
Version 1.99.7 (2012-03-12 21:59:21) dev
Version 1.99.7 (2012-03-12 22:34:49) dev
+7 -2
View File
@@ -55,11 +55,16 @@ __all__ = [
'IS_URL',
]
try:
from globals import current
have_current = True
except ImportError:
have_current = False
def translate(text):
if text is None:
return None
elif isinstance(text,(str,unicode)):
from globals import current
elif isinstance(text,(str,unicode)) and have_current:
if hasattr(current,'T'):
return str(current.T(text))
return str(text)