Commit Graph

19 Commits

Author SHA1 Message Date
Awais Qureshi
f1f1933ab4 BOM-2374
Run Pyupgrade on edxmako.
2021-03-05 18:17:41 +05:00
usamasadiq
515458b9dc Applied pylint-amnesty 2021-02-02 17:59:20 +05:00
Aarif
765942d7d2 Updated the template loaders to make them compatible with django 1.11,2.0 and above 2020-03-28 13:27:38 +05:00
David Ormsbee
5ce6cecfed Re-enable caching of context processor output
In Django template rendering, context processors only run once.
But when we do template rendering through edxmako (which we do for
each and every web fragment/XBlock), we can end up having hundreds
of invocations of templates and run context processors for each
separately. This removes that work.

This was originally added in ad5cc3d5 and reverted when we saw
errors in one of our environments that seemed to be related to
context processor code. Those errors persisted after the revert,
and so I'm adding this back in (with some modifications based on
review comments).
2020-02-25 17:48:45 -05:00
David Ormsbee
bb271e10e8 Revert "Request cache context processor output."
This reverts commit ad5cc3d5d9.

This was causing middleware errors while processing 404s.
2020-01-09 10:51:42 -05:00
David Ormsbee
ad5cc3d5d9 Request cache context processor output.
In Django template rendering, context processors only run once.
But when we do template rendering through edxmako (which we do for
each and every web fragment/XBlock), we can end up having hundreds
of invocations of templates and run context processors for each
separately. This removes that work.
2019-12-30 16:38:46 -05:00
Feanil Patel
6e3fe00fff Fix all E303 pep8 errors. 2019-12-30 12:25:38 -05:00
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Amit
328bcbe047 INCR-135: Run python-modernize on common/djangoapps/edxmako (#20483) 2019-05-09 10:08:57 -04:00
Jeremy Bowman
fdc50c3aa8 PLAT-1419 Make edxmako a proper template backend 2017-12-01 17:01:52 -05:00
Andy Armstrong
93235d118d Reorder imports using isort (except lms and cms) 2017-05-30 16:04:54 -04:00
Calen Pennington
25c4398125 Convert edxmako to use django_crum to get the current request 2016-06-08 16:35:24 -04:00
Ned Batchelder
4f9f87c192 Fix encoding of Django-called Mako files to be safe
The old code set the output-encoding to None, which means, I want
Unicode strings as output.  This made Mako pass markupsafe objects to
"unicode()", which applied all the escaping.  Then the result would be
given to Django, would would html-escape it again, resulting in
over-escaping.

By setting the output-encoding to utf8, we use filters.encode.utf8
instead, which is aware of Markupsafe, which avoids the over-escaping.
2016-04-11 14:00:15 -04:00
Andy Armstrong
4d75c18098 Fix Mako templates to use latest request context
Fixed the edX middleware to lazily create request
context for Mako templates, so that it is based on
any changes made to the request object.

Verified that with this fix the "Instructor" tab is
correctly hidden when a staff member is viewing
the course as a student.
2014-12-09 23:38:31 -05:00
Waheed Ahmed
d9ccaa650a Check REQUEST_CONTEXT.context exists before accessing it.
LMS-11226
2014-08-14 12:21:54 -04:00
Waheed Ahmed
05b87fd99b Implemented process_response method to clear requestcontext global variable in mako middleware.
LMS-6622
2014-08-06 19:58:20 +05:00
Chris Rossi
0a1ed11daa Make mako template lookups pluggable.
This code adds the ability to add Mako template lookup directories on
the fly, allowing third party add-ons to contribute their own Mako templates.
A new API function for registering Mako templates is introduced::

    from edxmako import add_lookup

    add_lookup('main', '/path/to/templates')

    # Or, specify a package to lookup using pkg_resources.  This will
    # add the 'templates' directory inside the current package:
    add_lookup('main', 'templates', package=__name__)
2014-01-31 13:55:36 -05:00
David Baumgold
b32f2bc170 MITX_ROOT_URL => EDX_ROOT_URL 2013-12-04 12:59:35 -05:00
David Baumgold
8eff442752 mitxmako => edxmako 2013-12-03 14:15:09 -05:00