Commit 236d7d46 by Chris Jerdonek

Removed View.__getitem__().

Note that the removed logic around issue #34 remains elsewhere in
the code in the Template._render_tag() method.
parent 33b26577
......@@ -11,6 +11,6 @@ class TemplatePartial(pystache.View):
def looping(self):
return [{'item': 'one'}, {'item': 'two'}, {'item': 'three'}]
def thing(self):
return self['prop']
\ No newline at end of file
return self.get('prop')
\ No newline at end of file
......@@ -136,17 +136,6 @@ class View(object):
def __contains__(self, needle):
return needle in self.context or hasattr(self, needle)
def __getitem__(self, attr):
val = self.get(attr, None)
# We use "==" rather than "is" to compare integers, as using "is" relies
# on an implementation detail of CPython. The test about rendering
# zeroes failed while using PyPy when using "is".
# See issue #34: https://github.com/defunkt/pystache/issues/34
if not val and val != 0:
raise KeyError("Key '%s' does not exist in View" % attr)
return val
def __getattr__(self, attr):
if attr == 'context':
return self._get_context()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment