add *args support to filters (or provide a proper error message)
|Reported by:||django@…||Owned by:||nobody|
|Cc:||ferringb@…||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Not sure if this should be an enhancement or a (doc) bug.
Currently you can not have a filter which takes *args.
The filter function introspection (in FilterExpression.args_check) does not check for *args (or kwdargs).
As a result, it thinks that there are 0 args required, and errors if any are passed in.
If the function in question does require some arguments, you get that error if you pass in nothing (the only way to get past args_check).
args_check COULD error if *args is present and no other args are present, but that has other issues.
This is causing me a headache due to the following:
@register.filter @threadsafe def not_thread_safe_filter(object, fmt): ## ... not mod_python thread safe code
This will hold true for all the generic decorators like threadsafe which just use (*args, kwdargs).
The obvious 'fix' would be to put the code from @threadsafe into the filter, which is what I have had to do, but that is a weak argument.
At the very least the doc needs to be patched to mention this issue.
Change History (4)
comment:1 Changed 9 years ago by Simon G. <dev@…>
- Triage Stage changed from Unreviewed to Design decision needed