sqlalchemy / sqlalchemy/mako

option to apply filters before the defaults ?

Open
#171 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

compiler feature low priority
Dominant language
Python
Stars
459
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Migrated issue, originally created by Anonymous

Maybe I am wrong here, but shouldn't default filters such as unicode() be applied last? The fact that it's done the exactly opposite way makes it a pain, as we are limited to deal with the string/unicode representation of whatever variable is passed to the filter.

Hence, I propose the following change:

diff -r 29d9a098a70465450563e9c07ed613e227886936 mako/codegen.py
--- a/mako/codegen.py   Fri Aug 05 17:45:51 2011 -0400
+++ b/mako/codegen.py   Mon Aug 08 11:14:48 2011 +0200
@@ -669,7 +669,7 @@
                 if self.compiler.pagetag:
                     args = self.compiler.pagetag.filter_args.args + args
                 if self.compiler.default_filters:
-                    args = self.compiler.default_filters + args
+                    args = args + self.compiler.default_filters
         for e in args:
             # if filter given as a function, get just the identifier portion
             if e == 'n':

What do you think?

Cheers,

Pedro

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in mako/codegen.py at the default_filters branch shown in the issue and review the comment discussion to clarify whether ordering should always change or be optional. Verify the resulting filter order for explicit and default filters, and ensure the behavior is covered by the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.