Skip to content
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

Remove default django template loaders. #11316

Merged
merged 1 commit into from
Feb 18, 2016

Conversation

mtyaka
Copy link
Contributor

@mtyaka mtyaka commented Jan 24, 2016

Mako filesystem/app_directories loaders already wrap default django template loaders.

Mako loaders delegate the load_template_source method to the base loader that they wrap, so there's no reason to explicitly include the two django loaders in the settings.

Partner information: 3rd party-hosted open edX instance
JIRA ticket: https://openedx.atlassian.net/browse/OSPR-1084
Sandbox URLs: TBD

@mtyaka mtyaka changed the title Remove default django template loaders. WIP: Remove default django template loaders. Jan 24, 2016
@mtyaka mtyaka force-pushed the remove-django-template-loaders branch from 75bf799 to a1c695c Compare January 25, 2016 07:22
@mtyaka mtyaka changed the title WIP: Remove default django template loaders. Remove default django template loaders. Jan 25, 2016
@openedx-webhooks
Copy link

Thanks for the pull request, @mtyaka! I've created OSPR-1084 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • edx-code email threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will still be done via the GitHub pull request interface. As a reminder, our process documentation is here.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U needs triage labels Jan 25, 2016
@Kelketek
Copy link
Contributor

👍

@nedbat
Copy link
Contributor

nedbat commented Jan 27, 2016

@mtyaka sorry for my ignorance, but I notice that cms settings don't include the Mako loaders. Do we not use Mako in Studio?? (I know this sounds like a really newb question...)

@nedbat
Copy link
Contributor

nedbat commented Jan 27, 2016

We do use Mako all over Studio. How is it being loaded? Why don't we need to make similar changes in "cms"?

@mtyaka
Copy link
Contributor Author

mtyaka commented Jan 27, 2016

@nedbat Yeah, that is a bit confusing. It took me a while to figure out how template rendering works in edx-platform.

Most of the time, we render main mako templates using edxmako.shortcuts.render_to_response. This completely bypasses django template loaders defined in TEMPLATES['OPTIONS']['loaders']. The only time these loaders are used is when rendering standard django (not mako) templates, and when either django or mako templates are included (with {% include '...' %}) inside standard django templates.

Some parts of the LMS (most notably the course wiki) use the main_django.html template, which is not a mako template, but it does {% include %} some mako templates. That's the only reason edxmako.makoloader.MakoFilesystemLoader and edxmako.makoloader.MakoAppDirectoriesLoader are needed - to be able to include mako templates inside django templates.

I guess in the CMS we never do that (include mako templates in django templates). We render mako templates directly using render_to_response. Some third party apps (for example debug tololbar) use django templates, but they never include mako templates, which is why in the CMS we don't have to use MakoFilesystemLoader/MakoAppDirectoriesLoader, but can use standard django filesystem.Loader/app_directories.Loader loaders instead.

Note that we could easily replace filesystem.Loader/app_directories.Loader in the CMS with MakoFilesystemLoader/MakoAppDirectoriesLoader and everything would continue to work exactly the same.

@nedbat
Copy link
Contributor

nedbat commented Jan 27, 2016

Could you add a comment about this in the settings where we set up the Mako loaders? Then we are good to go.

Mako filesystem/app_directories loaders already wrap default django template loaders.

Mako loaders delegate the `load_template_source` method to the base loader that
they wrap, so there's no reason to explicitly include the two django loaders in the settings.
@mtyaka mtyaka force-pushed the remove-django-template-loaders branch from a1c695c to 434f196 Compare January 28, 2016 08:33
@mtyaka
Copy link
Contributor Author

mtyaka commented Jan 28, 2016

@nedbat I added some comments to the settings and to the MakoLoader docstring.

@bradenmacdonald
Copy link
Contributor

@nedbat It sounds like you are happy with this - can we get your formal +1? And/or are we waiting for further review?

@mattdrayer
Copy link
Contributor

@mtyaka @nedbat @Kelketek -- sorry I am just now jumping in on this PR so forgive me while I get up to speed. Overall the change appears docile, however I am wondering if this is simply a code cleanup exercise or if the system's behavior is actually being affected by the change? It seems we are just doing some cleanup here? @ziafazal @saleem-latif, FYI

@mtyaka
Copy link
Contributor Author

mtyaka commented Feb 10, 2016

@mattdrayer Correct, this is just code cleanup, it should not have any effect on the way the system behaves.

@mattdrayer
Copy link
Contributor

👍

@openedx-webhooks openedx-webhooks added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Feb 15, 2016
@mtyaka mtyaka removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Feb 15, 2016
@nedbat
Copy link
Contributor

nedbat commented Feb 18, 2016

👍 Sorry for the delay.

@mtyaka
Copy link
Contributor Author

mtyaka commented Feb 18, 2016

Thanks!

mtyaka added a commit that referenced this pull request Feb 18, 2016
@mtyaka mtyaka merged commit f4e462c into openedx:master Feb 18, 2016
@bradenmacdonald bradenmacdonald deleted the remove-django-template-loaders branch May 18, 2019 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering review open-source-contribution PR author is not from Axim or 2U
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants