Opened 9 years ago

Closed 8 years ago

Last modified 8 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: master
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: UI/UX:


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:

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

comment:2 Changed 8 years ago by (removed)

  • Cc ferringb@… added

comment:3 Changed 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

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 Changed 8 years ago by dougn

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