Skip to content

Commit

Permalink
Support django 1.4 emtpy value in LazyDict. Closes #409
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Jul 22, 2012
1 parent 7bb5f4d commit e1b7f85
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions social_auth/utils.py
Expand Up @@ -68,6 +68,12 @@ def ct_compare(val1, val2):
return result == 0


try:
from django.utils.functional import empty
except ImportError: # django < 1.4
empty = None


get_random_string = random_string
constant_time_compare = ct_compare
utc = django_utc
Expand Down Expand Up @@ -230,12 +236,12 @@ def url_add_parameters(url, params):
class LazyDict(SimpleLazyObject):
"""Lazy dict initialization."""
def __getitem__(self, name):
if self._wrapped is None:
if self._wrapped is empty:
self._setup()
return self._wrapped[name]

def __setitem__(self, name, value):
if self._wrapped is None:
if self._wrapped is empty:
self._setup()
self._wrapped[name] = value

Expand Down

0 comments on commit e1b7f85

Please sign in to comment.