Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

magic-removal: Moved django.template.ContextPopException to django.te…

…mplate.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
  • Loading branch information...
commit 1b55e492eff85a65c96b84a5bfa42978a291392b 1 parent e6962ff
@adrianholovaty adrianholovaty authored
Showing with 16 additions and 16 deletions.
  1. +1 −5 django/template/__init__.py
  2. +15 −11 django/template/context.py
View
6 django/template/__init__.py
@@ -58,7 +58,7 @@
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 @@
class TemplateSyntaxError(Exception):
pass
-class ContextPopException(Exception):
- "pop() has been called more times than push()"
- pass
-
class TemplateDoesNotExist(Exception):
pass
View
26 django/template/context.py
@@ -3,11 +3,15 @@
_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 @@ def __setitem__(self, key, value):
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 @@ def __delitem__(self, key):
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):
Please sign in to comment.
Something went wrong with that request. Please try again.