From 2cc88a7a3233d6bd70ec174ba976d093dc7f0d98 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 7 Aug 2008 05:02:56 +0000 Subject: 74: Finished opt.__rules_iter(); is_rule(obj) now returns False if obj is not callable; updated unit tests --- ipalib/public.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ipalib/public.py') diff --git a/ipalib/public.py b/ipalib/public.py index b43e0af9..baae83e4 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -35,9 +35,7 @@ def rule(obj): return obj def is_rule(obj): - return getattr(obj, RULE_FLAG, False) is True - - + return callable(obj) and getattr(obj, RULE_FLAG, False) is True class opt(plugable.ReadOnly): @@ -65,7 +63,12 @@ class opt(plugable.ReadOnly): rules = property(__get_rules) def __rules_iter(self): - pass + for name in dir(self): + if name.startswith('_'): + continue + attr = getattr(self, name) + if is_rule(attr): + yield attr def validate(self, value): pass -- cgit