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:
Adrian Holovaty 2006-02-27 05:19:25 +00:00
parent e6962ff1a5
commit 1b55e492ef
2 changed files with 16 additions and 16 deletions

View File

@ -58,7 +58,7 @@ import re
from inspect import getargspec
from django.utils.functional import curry
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')
@ -93,10 +93,6 @@ builtins = []
class TemplateSyntaxError(Exception):
pass
class ContextPopException(Exception):
"pop() has been called more times than push()"
pass
class TemplateDoesNotExist(Exception):
pass

View File

@ -3,11 +3,15 @@ from django.core.exceptions import ImproperlyConfigured
_standard_context_processors = None
class ContextPopException(Exception):
"pop() has been called more times than push()"
pass
class Context:
"A stack container for variable context"
def __init__(self, dict=None):
dict = dict or {}
self.dicts = [dict]
def __init__(self, dict_=None):
dict_ = dict_ or {}
self.dicts = [dict_]
def __repr__(self):
return repr(self.dicts)
@ -30,9 +34,9 @@ class Context:
def __getitem__(self, key):
"Get a variable's value, starting at the current context and going upward"
for dict in self.dicts:
if dict.has_key(key):
return dict[key]
for d in self.dicts:
if d.has_key(key):
return d[key]
return settings.TEMPLATE_STRING_IF_INVALID
def __delitem__(self, key):
@ -40,15 +44,15 @@ class Context:
del self.dicts[0][key]
def has_key(self, key):
for dict in self.dicts:
if dict.has_key(key):
for d in self.dicts:
if d.has_key(key):
return True
return False
def get(self, key, otherwise):
for dict in self.dicts:
if dict.has_key(key):
return dict[key]
for d in self.dicts:
if d.has_key(key):
return d[key]
return otherwise
def update(self, other_dict):