comparison roundup/cgi/templating.py @ 5457:a35d4cc8cd1a

fix MissingValue / MockNull to return False on __bool__ and add a __contains__ to support 'in' operator correctly
author Christof Meerwald <cmeerw@cmeerw.org>
date Mon, 23 Jul 2018 21:45:05 +0100
parents 754be676ccc8
children ad8031290639
comparison
equal deleted inserted replaced
5456:0fb04e717de0 5457:a35d4cc8cd1a
3238 # client.db.config.TRACKER_WEB = 'BASE/' 3238 # client.db.config.TRACKER_WEB = 'BASE/'
3239 self.__dict__[name] = MissingValue(self.__description) 3239 self.__dict__[name] = MissingValue(self.__description)
3240 return getattr(self, name) 3240 return getattr(self, name)
3241 3241
3242 def __getitem__(self, key): return self 3242 def __getitem__(self, key): return self
3243 def __bool__(self): return 0 3243 def __bool__(self): return False
3244 # Python 2 compatibility: 3244 # Python 2 compatibility:
3245 __nonzero__ = __bool__ 3245 __nonzero__ = __bool__
3246 def __contains__(self, key): return False
3246 def __str__(self): return '[%s]'%self.__description 3247 def __str__(self): return '[%s]'%self.__description
3247 def __repr__(self): return '<MissingValue 0x%x "%s">'%(id(self), 3248 def __repr__(self): return '<MissingValue 0x%x "%s">'%(id(self),
3248 self.__description) 3249 self.__description)
3249 def gettext(self, str): return str 3250 def gettext(self, str): return str
3250 _ = gettext 3251 _ = gettext

Roundup Issue Tracker: http://roundup-tracker.org/