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

Add support for Django 1.8-1.10 #12

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

kezabelle
Copy link
Contributor

  • In Django 1.9, get_template_sources starts returning Origin objects.
  • _accepts_engine_in_init was a transitioning attribute, and now loaders always require an Engine
  • settings.TEMPLATE_LOADERS stops being used, being superceded by the TEMPLATES setting

The changes as given represent the minimum necessary to get a travis build working (see here) & also working in my local copy.

…EBUG setting, so we need to extract the Origin's directory name.
…tached to the engine, as such, we must extract them from the appropriate place, falling back to the old setting as necessary.

In 1.10, it looks like _accepts_engine_in_init is gone, and all loaders require the engine be passed down to their constructor.
@piotrkilczuk
Copy link
Member

Thank you @kezabelle - that's some great work!

I shall find time this week to review your Pull Request.

@tnm
Copy link

tnm commented Jan 26, 2017

This would be great! Seems straight-forward and tests look good.

@piotrkilczuk
Copy link
Member

Sorry it took so long. I have left some comments. Otherwise looks great.

@kezabelle can you see if these make sense?

try:
from django.utils import unittest
except ImportError:
import unittest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just add a comment explaining when does the ImportError happen and why we need to do it that way?

@@ -51,14 +55,24 @@ def find_all_templates(pattern='*.html'):
):
loader_class = getattr(import_module(module), klass)
if getattr(loader_class, '_accepts_engine_in_init', False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could rewrite that part not to use if getattr(loader_class, '_accepts_engine_in_init', False) - since we anyway need to handle the possible TypeError? Or is it better to keep it like that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could also inspect the signature of the __init__ method on the loader_class to establish whether it accepts an engine or not?

What do you think?

…g an engine to the loader, we can avoid checking the transitory variable _accepts_engine_in_init
@kezabelle
Copy link
Contributor Author

The worst thing about GitHub is being able to mark a notification as unread, so I entirely forgot about this.
@centralniak I've made some changes based on what you suggested, hopefully in the right direction :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants