Commit ab466c33 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Use getattr instead of hasattr. Use items instead of iteritems whenever possible.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14440 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c69b4e86
...@@ -92,18 +92,18 @@ class Predicate(XMLObject, Folder): ...@@ -92,18 +92,18 @@ class Predicate(XMLObject, Folder):
""" """
self = self.asPredicate() self = self.asPredicate()
result = 1 result = 1
if not hasattr(aq_base(self), '_identity_criterion'): if getattr(aq_base(self), '_identity_criterion', None) is None:
self._identity_criterion = {} self._identity_criterion = {}
self._range_criterion = {} self._range_criterion = {}
# LOG('PREDICATE TEST', 0, # LOG('PREDICATE TEST', 0,
# 'testing %s on context of %s' % \ # 'testing %s on context of %s' % \
# (self.getRelativeUrl(), context.getRelativeUrl())) # (self.getRelativeUrl(), context.getRelativeUrl()))
for property, value in self._identity_criterion.items(): for property, value in self._identity_criterion.iteritems():
result = result and (context.getProperty(property) == value) result = result and (context.getProperty(property) == value)
# LOG('predicate test', 0, # LOG('predicate test', 0,
# '%s after prop %s : %s == %s' % \ # '%s after prop %s : %s == %s' % \
# (result, property, context.getProperty(property), value)) # (result, property, context.getProperty(property), value))
for property, (min, max) in self._range_criterion.items(): for property, (min, max) in self._range_criterion.iteritems():
value = context.getProperty(property) value = context.getProperty(property)
if min is not None: if min is not None:
result = result and (value >= min) result = result and (value >= min)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment