~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to django/template/context.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from django.conf import settings
2
1
from django.core.exceptions import ImproperlyConfigured
 
2
from django.utils.importlib import import_module
3
3
 
4
4
_standard_context_processors = None
5
5
 
9
9
 
10
10
class Context(object):
11
11
    "A stack container for variable context"
12
 
    def __init__(self, dict_=None, autoescape=True):
 
12
    def __init__(self, dict_=None, autoescape=True, current_app=None):
13
13
        dict_ = dict_ or {}
14
14
        self.dicts = [dict_]
15
15
        self.autoescape = autoescape
 
16
        self.current_app = current_app
16
17
 
17
18
    def __repr__(self):
18
19
        return repr(self.dicts)
62
63
 
63
64
    def update(self, other_dict):
64
65
        "Like dict.update(). Pushes an entire dictionary's keys and values onto the context."
65
 
        if not hasattr(other_dict, '__getitem__'): 
 
66
        if not hasattr(other_dict, '__getitem__'):
66
67
            raise TypeError('other_dict must be a mapping (dictionary-like) object.')
67
68
        self.dicts = [other_dict] + self.dicts
68
69
        return other_dict
70
71
# This is a function rather than module-level procedural code because we only
71
72
# want it to execute if somebody uses RequestContext.
72
73
def get_standard_processors():
 
74
    from django.conf import settings
73
75
    global _standard_context_processors
74
76
    if _standard_context_processors is None:
75
77
        processors = []
77
79
            i = path.rfind('.')
78
80
            module, attr = path[:i], path[i+1:]
79
81
            try:
80
 
                mod = __import__(module, {}, {}, [attr])
 
82
                mod = import_module(module)
81
83
            except ImportError, e:
82
84
                raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))
83
85
            try:
95
97
    Additional processors can be specified as a list of callables
96
98
    using the "processors" keyword argument.
97
99
    """
98
 
    def __init__(self, request, dict=None, processors=None):
99
 
        Context.__init__(self, dict)
 
100
    def __init__(self, request, dict=None, processors=None, current_app=None):
 
101
        Context.__init__(self, dict, current_app=current_app)
100
102
        if processors is None:
101
103
            processors = ()
102
104
        else: