Jonathan LaCour wrote
> Sure, but I still want to be able to turn them off, even if it
> does break some "future" extension. The bottom line for me is that
> I totally understand (and agree with) your arguments, but I still
> think that there needs to be a mechanism for clearing out the
> default rules to give the user complete control over them.
>
Just found out how you can do this:
>>> from peak.rules import Dispatching, when
>>> def f(n): pass
...
>>> f(6)
>>> when(f, "n>5")(lambda n: n)
<function <lambda> at 0x862325c>
>>> f(6)
6
>>> rule_set = Dispatching(f).rules
>>> rule_set.rules
[Rule(<function f at 0x862341c>, (), None, 121), Rule(<function <lambda>
at 0x862325c>, Test(Comparison(Local('n')), Range((5, 1), (Max, 1))),
None, 122)]
>>> rule_set.remove(rule_set.rules[1])
>>> f(6)
I'm loving this PEAK-rules thing... :)
Alberto
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---