[PEAK] Use cases for the priority feature

P.J. Eby pje at telecommunity.com
Tue Aug 17 18:56:12 EDT 2010


At 11:48 PM 8/17/2010 +0200, Alberto Valverde wrote:
>  Hi,
>
>Another use-case for the priority feature is when you're extending a 
>framework's generic function (eg: jsonify) and you can't (or don't 
>want to) modify its source to avoid a conflict with the rule you 
>want to register. In this hypothetical case "around" can't be used 
>either since the framework (or another library) already defines an 
>around method. The only way would be to write a more specific rule 
>but this can be tedious and verbose.

Hm.  Maybe I should just add a way to remove or replace an existing 
method, e.g.:

    remove(func, "condition")

There is already "rules_for(func).remove(rule)", but you must know 
the rule object.  I could add something to let you find the rules 
matching a specific condition.

This seems more explicit to me than just sticking a magic number on 
the end of something.

I also could potentially add a 'replace' keyword argument to 
decorators, so you can replace an existing rule -- and you'd get an 
error if you tried to replace something that didn't exist.

Your thoughts?



More information about the PEAK mailing list