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

Django 1.9 (WIP) #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ python: 2.7
env:
- DJANGO_VERSION=1.7.*
- DJANGO_VERSION=1.8.*
- DJANGO_VERSION=1.9.*
install:
- pip install django==$DJANGO_VERSION
- python setup.py install
Expand Down
15 changes: 14 additions & 1 deletion src/extras/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@
from inspect import getargspec

from django.template import Context
from django.template.base import generic_tag_compiler, TagHelperNode, Template
try:
from django.template.base import generic_tag_compiler, TagHelperNode, Template
except ImportError:

Choose a reason for hiding this comment

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

It seems like this is a fine solution for now, but I think going forward unfortunately we're going to need a version check, and different code for each version with significant changes. In particular, backporting any changes when we're already trying to merge different versions of the code seems like it's just an impossible mess.

Also, I think it's probably better to do an explicit version check instead of try/except?

# Django 1.9+
from django.template.base import Template
from django.template.library import parse_bits, TagHelperNode

# copied from Django 1.8 source, since this function was removed in 1.9
def generic_tag_compiler(parser, token, params, varargs, varkw, defaults,
name, takes_context, node_class):
bits = token.split_contents()[1:]
args, kwargs = parse_bits(parser, bits, params, varargs, varkw,
defaults, takes_context, name)
return node_class(takes_context, args, kwargs)
from django.utils.itercompat import is_iterable
from django.utils import six

Expand Down
6 changes: 1 addition & 5 deletions src/marinade.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from django.db.models import Model
from django.db.models.query import QuerySet
from django.contrib.auth.models import AnonymousUser

from .utils import force_str

Expand Down Expand Up @@ -58,10 +57,7 @@ def marinade_dish(arg):
if isinstance(arg, list):
return '[%s]' % ','.join([marinade_dish(item) for item in arg])
if isinstance(arg, Model):
# ESPUsers are also instances of AnonymousUser, but might not be
# anonymous.
if arg.id is None and (not isinstance(arg, AnonymousUser) or
not arg.is_anonymous()):
if arg.id is None:
import random
# TODO: Make this log something
print "PASSING UNSAVED MODEL!!! ERROR!!! CACHING CODE SHOULD NOT BE ENABLED!!!"
Expand Down