-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add default helper filters #130
Conversation
Codecov Report
@@ Coverage Diff @@
## master #130 +/- ##
=======================================
- Coverage 100% 0% -100%
=======================================
Files 1 2 +1
Lines 79 96 +17
Branches 10 13 +3
=======================================
- Hits 79 0 -79
- Misses 0 96 +96
Continue to review full report at Codecov.
|
|
||
|
||
@jinja2.contextfilter | ||
def reverse_url(context, name_, **parts): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather leave name_
as __aiohttp_jinja2_route_name
to prevent names conflict here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use __name
-- the chance of conflict is reasonable low with this name
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.4', | ||
'Programming Language :: Python :: 3.5', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets add 3.6 entry as well as 'Framework :: AsyncIO',
@@ -1,12 +0,0 @@ | |||
flake8==3.3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use pyup
bot to track dependencies updates like here #129 Could you please check if pyup
bot work with setup.py too. Otherwise lets leave as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is ongoing development for adding support to use setup.py
file as source of requirements pyupio/pyup#137. Anyway I get the case and will revert that changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't.
Please revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left very many comments but my main question is: why do we need the feature at all?
Prom my perspective {{ url('name', arg=val) }}
is prettier and more native than {{ 'name' | url(arg=val) }}
.
The last notation is very confusing.
|
||
|
||
@jinja2.contextfilter | ||
def reverse_url(context, name_, **parts): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use __name
-- the chance of conflict is reasonable low with this name
kwargs['query'] = parts.pop('query') | ||
if parts: | ||
kwargs['parts'] = parts | ||
return app.router[name_].url(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.url_for
should be used
""" | ||
app = context['app'] | ||
kwargs = {} | ||
if 'query' in parts: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't process query
separately.
def reverse_url(context, name_, **parts): | ||
"""Filter for generating urls. | ||
|
||
See http://aiohttp.readthedocs.io/en/stable/web.html# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use sphinx autodocs for documentation generation.
Please drop the tail of docstring but update docs/index.rst
|
||
|
||
@jinja2.contextfilter | ||
def reverse_url(context, name_, **parts): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest url_for()
name
@@ -1,12 +0,0 @@ | |||
flake8==3.3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't.
Please revert.
sorry, I hadn't seen this. I'll update my PR to reflex @asvetlov's requested changes. I think setup changes should go in a separate PR. |
closing this one and will pick small improvements for |
Rationale
We want to have optional list of default filters for jinja environment that will be hidden with a feature flag
default_filters
. Those will provide unified interface of adding some usefuljinja2.contextfilter
filters within a package.TODO
Notes
@samuelcolvin I've included minor not related changes to
setup
file, but besides that let's collaborate on this to deliver the feature.