[Zope-Checkins] CVS: Zope3/lib/python/Zope/PageTemplate - TALES.py:1.1.2.14

Fred L. Drake, Jr. fdrake@acm.org
Fri, 24 May 2002 11:46:48 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/PageTemplate
In directory cvs.zope.org:/tmp/cvs-serv30683/PageTemplate

Modified Files:
      Tag: Zope-3x-branch
	TALES.py 
Log Message:
Make the Python value for "default" evaluate as true in a Boolean context.
Rename default_ to _default since it is not part of the public API (and is
not referenced elsewhere).


=== Zope3/lib/python/Zope/PageTemplate/TALES.py 1.1.2.13 => 1.1.2.14 ===
 __version__ = '$Revision$'[11:-2]
 
-import re, sys
+import re
+import sys
 from types import StringType
 
 import Zope.ZTUtils
@@ -44,11 +45,7 @@
     '''Expression type or base name registration Error'''
 
 
-class Default:
-    '''Retain Default'''
-    def __nonzero__(self):
-        return 0
-default_ = Default()
+_default = object()
 
 _marker = object()
 
@@ -165,7 +162,7 @@
         self._engine = engine
         self.contexts = contexts
         contexts['nothing'] = None
-        contexts['default'] = default_
+        contexts['default'] = _default
 
         self.repeat_vars = rv = {}
         # Wrap this, as it is visible to restricted code
@@ -230,7 +227,7 @@
 
     def evaluateText(self, expr):
         text = self.evaluate(expr)
-        if text is default_ or text is None:
+        if text is _default or text is None:
             return text
         return str(text)
 
@@ -247,7 +244,7 @@
         return ErrorInfo(err, position)
 
     def getDefault(self):
-        return default_
+        return _default
 
     def setSourceFile(self, source_file):
         self.source_file = source_file