Opened 18 years ago

Closed 17 years ago

Last modified 17 years ago

#2537 closed enhancement (wontfix)

add *args support to filters (or provide a proper error message)

Reported by: django@… Owned by: nobody
Component: Template system Version: dev
Severity: normal Keywords:
Cc: ferringb@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by (removed), 18 years ago

Cc: ferringb@… added

comment:3 by Jacob, 17 years ago

Resolution: wontfix
Status: newclosed

At the moment, filters don't take multiple arguments -- i.e. they either take an argument, or they don't. So using *args doesn't really get you anywhere over using def filter(value, arg=None).

comment:4 by dougn, 17 years ago

NOTE: at the time this bug was filed over a year ago, arg=None was not supported by filter expressions, and 'None' was not a valid variable.

'fixed' by alternate implementation which achieves the same goal would be more appropriate.

Note: See TracTickets for help on using tickets.
Back to Top