Ticket #15368: 15368_lp_solution.diff

File 15368_lp_solution.diff, 2.2 KB (added by Luke Plant, 14 years ago)

my solution

  • django/template/context.py

    diff -r f38db5003acc django/template/context.py
    a b  
    1919        dict_ = dict_ or {}
    2020        self.dicts = [dict_]
    2121
    22     def __copy__(self):
    23         duplicate = self._new()
    24         duplicate.dicts = [dict_ for dict_ in self.dicts]
     22    def copy(self):
     23        duplicate = copy(self)
     24        duplicate.dicts = self.dicts[:]
    2525        return duplicate
    2626
    2727    def __repr__(self):
     
    3131        for d in reversed(self.dicts):
    3232            yield d
    3333
    34     def _new(self):
    35         return self.__class__()
    36 
    3734    def push(self):
    3835        d = {}
    3936        self.dicts.append(d)
     
    8380        self.render_context = RenderContext()
    8481        super(Context, self).__init__(dict_)
    8582
    86     def __copy__(self):
    87         duplicate = super(Context, self).__copy__()
     83    def copy(self):
     84        duplicate = super(Context, self).copy()
    8885        duplicate.render_context = copy(self.render_context)
    8986        return duplicate
    9087
    91     def _new(self):
    92         return self.__class__(autoescape=self.autoescape,
    93                               current_app=self.current_app,
    94                               use_l10n=self.use_l10n)
    95 
    9688    def update(self, other_dict):
    9789        "Pushes other_dict to the stack of dictionaries in the Context"
    9890        if not hasattr(other_dict, '__getitem__'):
     
    168160            processors = tuple(processors)
    169161        for processor in get_standard_processors() + processors:
    170162            self.update(processor(request))
    171 
    172     def _new(self):
    173         return self.__class__(request=HttpRequest(),
    174                               current_app=self.current_app,
    175                               use_l10n=self.use_l10n)
  • django/test/client.py

    diff -r f38db5003acc django/test/client.py
    a b  
    9797    of rendering.
    9898    """
    9999    store.setdefault('templates', []).append(template)
    100     store.setdefault('context', ContextList()).append(copy(context))
     100    store.setdefault('context', ContextList()).append(context.copy())
    101101
    102102def encode_multipart(boundary, data):
    103103    """
Back to Top