Skip to content

Commit be08fda

Browse files
author
Adam Chainz
committed
Django 1.9 compatibility
Fixes disqus#3. Tested with `python -WError` added to `tox` file, no warnings popped up.
1 parent 73f82a3 commit be08fda

File tree

7 files changed

+36
-19
lines changed

7 files changed

+36
-19
lines changed

CHANGES

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Pending
2+
3+
- Support for Django 1.9
4+
15
0.11.0
26

37
- Better support for Django 1.6 and Django 1.7
@@ -82,4 +86,4 @@
8286
- Added ConditionSet.has_active_condition, and support for default NoneType instances
8387
for global / environment checks.
8488
- Added HostConditionSet which allows you to specify a switch for a single
85-
server hostname
89+
server hostname

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Requirements
1818
Tested with all combinations of:
1919

2020
* Python: 2.7
21-
* Django: 1.7, 1.8
21+
* Django: 1.7, 1.8, 1.9
2222

2323
Install
2424
-------

gargoyle/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DISABLED = 1
2+
SELECTIVE = 2
3+
GLOBAL = 3
4+
INHERIT = 4
5+
6+
INCLUDE = 'i'
7+
EXCLUDE = 'e'

gargoyle/manager.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from django.conf import settings
22
from django.core.cache import caches
33
from django.http import HttpRequest
4+
from django.utils.functional import SimpleLazyObject
45
from modeldict import ModelDict
56

6-
from gargoyle.models import DISABLED, EXCLUDE, GLOBAL, INCLUDE, INHERIT, SELECTIVE, Switch
77
from gargoyle.proxy import SwitchProxy
88

9+
from .constants import DISABLED, EXCLUDE, GLOBAL, INCLUDE, INHERIT, SELECTIVE
10+
911

1012
class SwitchManager(ModelDict):
1113
DISABLED = DISABLED
@@ -144,10 +146,19 @@ def as_request(self, user=None, ip_address=None):
144146
return MockRequest(user, ip_address)
145147

146148

147-
if hasattr(settings, 'GARGOYLE_CACHE_NAME'):
148-
gargoyle = SwitchManager(Switch, key='key', value='value', instances=True,
149-
auto_create=getattr(settings, 'GARGOYLE_AUTO_CREATE', True),
150-
cache=caches[settings.GARGOYLE_CACHE_NAME])
151-
else:
152-
gargoyle = SwitchManager(Switch, key='key', value='value', instances=True,
153-
auto_create=getattr(settings, 'GARGOYLE_AUTO_CREATE', True))
149+
def make_gargoyle():
150+
from gargoyle.models import Switch
151+
152+
kwargs = {
153+
'key': 'key',
154+
'value': 'value',
155+
'instances': True,
156+
'auto_create': getattr(settings, 'GARGOYLE_AUTO_CREATE', True),
157+
}
158+
159+
if hasattr(settings, 'GARGOYLE_CACHE_NAME'):
160+
kwargs['cache'] = caches[settings.GARGOYLE_CACHE_NAME]
161+
162+
return SwitchManager(Switch, **kwargs)
163+
164+
gargoyle = SimpleLazyObject(make_gargoyle)

gargoyle/models.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
from django.utils.translation import ugettext_lazy as _
1212
from jsonfield import JSONField
1313

14-
DISABLED = 1
15-
SELECTIVE = 2
16-
GLOBAL = 3
17-
INHERIT = 4
18-
19-
INCLUDE = 'i'
20-
EXCLUDE = 'e'
14+
from .constants import DISABLED, EXCLUDE, GLOBAL, INCLUDE, INHERIT, SELECTIVE
2115

2216

2317
class Switch(models.Model):

gargoyle/templates/gargoyle/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{% extends "nexus/module.html" %}
22

33
{% load gargoyle_helpers %}
4-
{% load url from future %}
54

65
{% block head %}
76
{{ block.super }}

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[tox]
22
envlist =
33
py27-codestyle,
4-
py27-nexus{10,master}-django{17,18}
4+
py27-nexus10-django{17,18},
5+
py27-nexusmaster-django{17,18,19}
56

67
[testenv]
78
setenv =
@@ -12,6 +13,7 @@ deps =
1213
nexusmaster: https://github.com/YPlan/nexus/archive/master.tar.gz
1314
django17: Django>=1.7,<1.8
1415
django18: Django>=1.8,<1.9
16+
django19: Django>=1.9,<1.10
1517
-rrequirements.txt
1618
commands = ./runtests.py --nolint {posargs}
1719

0 commit comments

Comments
 (0)