1. Mike Bayer
  2. mako


Issue #219 resolved

Context.locals_() does not update the returned Context's `kwargs` attribute

created an issue

unit test:

class ContextTest(unittest.TestCase):
  def test_locals_kwargs(self):
    c = Context(None, foo='bar')
    self.assertEqual(c.kwargs, {'foo': 'bar'})
    d = c.locals_({'zig': 'zag'})
    self.assertEqual(c.kwargs, {'foo': 'bar'})
    self.assertEqual(d.kwargs, {'foo': 'bar', 'zig': 'zag'})

attached is a patch for mako 0.7.2.

Comments (2)

  1. Mike Bayer repo owner

    thanks for this - I haven't looked at this code in over a year, is there a template-oriented use case you can show me that's impacted by this ?

  2. Mike Bayer repo owner

    OK not sure what your use case was since I don't have one here, if it was that you were calling locals_() yourself for something, that's not what its for, and if it was that you were using context.kwargs and expecting some local variable or something to be present inside of it, that's also not what its for, else there would be no need for kwargs to be maintained separately in the first place. So locals_() is now _locals() and documentation has been clarified in 420a0831eedd9c0679.

  3. Log in to comment