Code

Ticket #3192: dict-to-update.diff

File dict-to-update.diff, 559 bytes (added by Jeremy Dunck <jdunck@…>, 8 years ago)

Another diff in case preference is to enforce in Context.update rather than RequestContext.init

Line 
1Index: template/context.py
2===================================================================
3--- template/context.py (revision 4248)
4+++ template/context.py (working copy)
5@@ -57,6 +57,8 @@
6 
7     def update(self, other_dict):
8         "Like dict.update(). Pushes an entire dictionary's keys and values onto the context."
9+        if not hasattr(other_dict, '__getitem__'):
10+            raise TypeError, 'Dictionary expected.'
11         self.dicts = [other_dict] + self.dicts
12 
13 # This is a function rather than module-level procedural code because we only