On Mon, Jun 22, 2009 at 7:18 PM, Gustavo Narea<[email protected]> wrote: > > Gustavo said: >> """ >> def __getattr__(self, name): >> original_class = self.get_predicate_checker(name) >> class BooleanPredicate(original_class): >> def __nonzero__(self,): >> return self.is_met() >> return BooleanPredicate >> """ > > Sorry, forgot to explain how get_predicate_checker() would look like: > """ > def get_predicate_checker(self, name): > for mod in self.predicate_modules: > if hasattr(mod, name): > return getattr(mod, name) > raise NameError(...) > """ > > As a consequence: > 1.- User-defined predicate checkers could be used in the same namespace. > 2.- This could also be used in the controllers, not only in the templates.
We would need some nice name for the "overloader" and I think it could settle all those discussions flaring on the mailing list at the moment. Florent. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears Trunk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/turbogears-trunk?hl=en -~----------~----~----~----~------~----~------~--~---
