magic-removal: Moved django.template.ContextPopException to django.template.context module, where the code that calls it can find it. Also removed use of 'dict' as a local variable, because that's a Python builtin
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2408 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e6962ff1a5
commit
1b55e492ef
|
@ -58,7 +58,7 @@ import re
|
||||||
from inspect import getargspec
|
from inspect import getargspec
|
||||||
from django.utils.functional import curry
|
from django.utils.functional import curry
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template.context import Context, RequestContext
|
from django.template.context import Context, RequestContext, ContextPopException
|
||||||
|
|
||||||
__all__ = ('Template', 'Context', 'RequestContext', 'compile_string')
|
__all__ = ('Template', 'Context', 'RequestContext', 'compile_string')
|
||||||
|
|
||||||
|
@ -93,10 +93,6 @@ builtins = []
|
||||||
class TemplateSyntaxError(Exception):
|
class TemplateSyntaxError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ContextPopException(Exception):
|
|
||||||
"pop() has been called more times than push()"
|
|
||||||
pass
|
|
||||||
|
|
||||||
class TemplateDoesNotExist(Exception):
|
class TemplateDoesNotExist(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,15 @@ from django.core.exceptions import ImproperlyConfigured
|
||||||
|
|
||||||
_standard_context_processors = None
|
_standard_context_processors = None
|
||||||
|
|
||||||
|
class ContextPopException(Exception):
|
||||||
|
"pop() has been called more times than push()"
|
||||||
|
pass
|
||||||
|
|
||||||
class Context:
|
class Context:
|
||||||
"A stack container for variable context"
|
"A stack container for variable context"
|
||||||
def __init__(self, dict=None):
|
def __init__(self, dict_=None):
|
||||||
dict = dict or {}
|
dict_ = dict_ or {}
|
||||||
self.dicts = [dict]
|
self.dicts = [dict_]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return repr(self.dicts)
|
return repr(self.dicts)
|
||||||
|
@ -30,9 +34,9 @@ class Context:
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
"Get a variable's value, starting at the current context and going upward"
|
"Get a variable's value, starting at the current context and going upward"
|
||||||
for dict in self.dicts:
|
for d in self.dicts:
|
||||||
if dict.has_key(key):
|
if d.has_key(key):
|
||||||
return dict[key]
|
return d[key]
|
||||||
return settings.TEMPLATE_STRING_IF_INVALID
|
return settings.TEMPLATE_STRING_IF_INVALID
|
||||||
|
|
||||||
def __delitem__(self, key):
|
def __delitem__(self, key):
|
||||||
|
@ -40,15 +44,15 @@ class Context:
|
||||||
del self.dicts[0][key]
|
del self.dicts[0][key]
|
||||||
|
|
||||||
def has_key(self, key):
|
def has_key(self, key):
|
||||||
for dict in self.dicts:
|
for d in self.dicts:
|
||||||
if dict.has_key(key):
|
if d.has_key(key):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get(self, key, otherwise):
|
def get(self, key, otherwise):
|
||||||
for dict in self.dicts:
|
for d in self.dicts:
|
||||||
if dict.has_key(key):
|
if d.has_key(key):
|
||||||
return dict[key]
|
return d[key]
|
||||||
return otherwise
|
return otherwise
|
||||||
|
|
||||||
def update(self, other_dict):
|
def update(self, other_dict):
|
||||||
|
|
Loading…
Reference in New Issue