I think I have found some strange behaviour in Pylons and it is repeatable.
It is related to _ (gettext) function and having debug sessions with
nice Pylons 'Error Traceback' console

How to repeat:

1) request /testing/debug which raises exception on purpose
code:
class TestingController(MyBaseController):
    def debug(self):
        raise debugging_console_in_browser()


1a) use the console to inspect some variables.
code:
request.cookies
in my case it gives:
>>> request.cookies
{'portal': '55da4a783da7a244abe0258bc769fdeb8c997d6274ddde81afe285239fb5e441'}

2) request another valid page which uses i18n gettext in Mako
template, i.e ${_('hello')} and this page
should not throw any error

2b) this page will raise exception saying - depending on one's
inspections of variables in previous request:
- exceptions.TypeError: 'dict' object is not callable
- or: exceptions.TypeError: 'unicode' object is not callable
- or a list is not callable
- etc...

2c) Stacktrace (in case with showing 'request.cookies' variable in
console in 1st request):
File '.../project/controllers/testing.py', line 8 in i18n
  return render('/testing/i18n.tmpl')
File 
'/usr/lib/python2.4/site-packages/Pylons-0.9.6.1-py2.4.egg/pylons/templating.py',
line 343 in render
  format=format, namespace=kargs, **cache_args)
File 
'/usr/lib/python2.4/site-packages/Pylons-0.9.6.1-py2.4.egg/pylons/templating.py',
line 227 in render
  return engine_config['engine'].render(namespace, template=full_path,
File 
'/usr/lib/python2.4/site-packages/Mako-0.1.9-py2.4.egg/mako/ext/turbogears.py',
line 49 in render
  return template.render(**info)
File '/usr/lib/python2.4/site-packages/Mako-0.1.9-py2.4.egg/mako/template.py',
line 114 in render
  return runtime._render(self, self.callable_, args, data)
File '/usr/lib/python2.4/site-packages/Mako-0.1.9-py2.4.egg/mako/runtime.py',
line 287 in _render
  _render_context(template, callable_, context, *args,
**_kwargs_for_callable(callable_, data))
File '/usr/lib/python2.4/site-packages/Mako-0.1.9-py2.4.egg/mako/runtime.py',
line 304 in _render_context
  _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File '/usr/lib/python2.4/site-packages/Mako-0.1.9-py2.4.egg/mako/runtime.py',
line 337 in _exec_template
  callable_(context, *args, **kwargs)
File '/.../project/data/templates/base.tmpl.py', line 83 in render_body
  context.write(unicode(self.default_content()))
File '/usr/lib/python2.4/site-packages/Mako-0.1.9-py2.4.egg/mako/runtime.py',
line 193 in <lambda>
  return lambda *args, **kwargs:callable_(self.context, *args, **kwargs)
File '/.../project/data/templates/base.tmpl.py', line 207 in
render_default_content
  context.write(unicode(next.body()))
File '/usr/lib/python2.4/site-packages/Mako-0.1.9-py2.4.egg/mako/runtime.py',
line 193 in <lambda>
  return lambda *args, **kwargs:callable_(self.context, *args, **kwargs)
File '.../project/data/templates/testing/i18n.tmpl.py', line 57 in render_body
  context.write(unicode(_('hello')))
TypeError: 'dict' object is not callable


2d) when printing _ in current console it says!:
>>> _
{'portal': '55da4a783da7a244abe0258bc769fdeb8c997d6274ddde81afe285239fb5e441'}

WHAT IS IN FACT a variable inspected in 1st request
but should be gettext function


3) so it looks that _ was substituted to whatever I have last used in
previous request's debug session's console

!?

4) now all requests using _ in templates will fail
5) rm -rf data/templates/* data/sessions/* helps

;)

-- 
_i______'simplicity_is_the_key'__________tomasz_nazar
_ii____'i_am_concern_oriented'________________JKM-UPR
_iii__'patsystem.sf.net'___________________linux_user
_'aspectized.com'___________________________prevayler

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to