From f556c9cd8da9596b798f7b3e01afd160bf117fcb Mon Sep 17 00:00:00 2001 From: Massimo DiPierro Date: Mon, 12 Mar 2012 22:34:52 -0500 Subject: [PATCH] validators optionally require globals --- VERSION | 2 +- gluon/validators.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index d64ca6b5..04b89b80 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.7 (2012-03-12 21:59:21) dev +Version 1.99.7 (2012-03-12 22:34:49) dev diff --git a/gluon/validators.py b/gluon/validators.py index 206721a3..39f845d2 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -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)