Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#16726 closed Cleanup/optimization (duplicate)

Make is_safe decorator for filters

Reported by: kostia.balitsky@… Owned by: Jannis Leidel
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Why not turn boring process of coding

@register.filter('amazing')
def amazing(value):
    # Not doing anything unsafe ;)
    ...
    return new_value
amazing.is_safe = True

into something more interesting like

@register.safe_filter('amazing')
def amazing(value):
    # Not doing anything unsafe ;)
    ...
    return new_value 

?

Change History (9)

comment:1 by Jannis Leidel, 13 years ago

Triage Stage: UnreviewedAccepted
Type: New featureCleanup/optimization
Version: 1.2SVN

comment:2 by Russell Keith-Magee, 13 years ago

I'd much rather see a separate @is_safe decorator, rather than a single-purpose @safe_filter.

comment:3 by Jannis Leidel, 13 years ago

Sounds good to me, too.

in reply to:  2 comment:4 by anonymous, 13 years ago

Replying to russellm:

I'd much rather see a separate @is_safe decorator, rather than a single-purpose @safe_filter.

It's not a big deal to implement both of them :)

comment:5 by Jannis Leidel, 13 years ago

Owner: changed from nobody to Jannis Leidel
Status: newassigned

comment:6 by Jannis Leidel, 13 years ago

Resolution: duplicate
Status: assignedclosed

Actually this is a dupe of #6135.

comment:7 by Jannis Leidel, 13 years ago

.. at least in the sense that both is_safe and needs_autoescape only set a flag on the filter functions.

in reply to:  7 comment:8 by anonymous, 13 years ago

Replying to jezdez:

.. at least in the sense that both is_safe and needs_autoescape only set a flag on the filter functions.

But they are supposed to do different things, correct?

comment:9 by Aymeric Augustin, 13 years ago

In [17056]:

Fixed #17135 -- Made it possible to use decorators (like stringfilter) on template filter functions in combination with auto-escaping. Refs #16726.

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