GithubHelp home page GithubHelp logo

malthe / chameleon Goto Github PK

View Code? Open in Web Editor NEW
174.0 174.0 64.0 2.36 MB

Fast HTML/XML template engine for Python

Home Page: https://chameleon.readthedocs.io

License: Other

Makefile 1.04% Python 98.66% HTML 0.30%

chameleon's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chameleon's Issues

portal_state not available

Here's the latest failure I'm getting under five.pt 2.1.2 that I'm not getting without it:

Failed example:
browser.open(portal.news.absolute_url())
Exception raised:
Traceback (most recent call last):
File "/home/xen/src/python/parts/opt/lib/python2.7/doctest.py", line 1254, in **run
compileflags, 1) in test.globs
File "<doctest autogroup.txt[17]>", line 1, in
browser.open(portal.news.absolute_url())
File "/usr/local/lib/python/site-packages/zope.testbrowser-3.6.0a2-py2.7.egg/zope/testbrowser/browser.py", line 239, in open
self.mech_browser.open(url, data)
File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_mechanize.py", line 209, in open
return self._mech_open(url, data, timeout=timeout)
File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_mechanize.py", line 236, in _mech_open
response = UserAgentBase.open(self, request, data)
File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_opener.py", line 191, in open
response = urlopen(self, req, data)
File "/home/xen/src/python/parts/opt/lib/python2.7/urllib2.py", line 412, in _open
'_open', req)
File "/home/xen/src/python/parts/opt/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(_args)
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Products/Five/testbrowser.py", line 85, in http_open
return self.do_open(PublisherConnection, req)
File "/home/xen/src/python/parts/opt/lib/python2.7/urllib2.py", line 1168, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/local/lib/python/site-packages/zope.testbrowser-3.6.0a2-py2.7.egg/zope/testbrowser/testing.py", line 82, in request
self.response = self.caller(request_string, handle_errors)
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Testing/ZopeTestCase/functional.py", line 40, in wrapped_func
return func(_args, kw)
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Testing/ZopeTestCase/zopedoctest/functional.py", line 188, in http
debug=not handle_errors,
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/Test.py", line 204, in publish_module
response = publish(request, module_name, after_list, debug=debug)
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/Publish.py", line 127, in publish
request, bind=1)
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/mapply.py", line 77, in mapply
if debug is not None: return debug(object,args,context)
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/Publish.py", line 47, in call_object
result=apply(object,args) # Type s to step into published object.
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Shared/DC/Scripts/Bindings.py", line 324, in __call

return self._bindAndExec(args, kw, None)
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Shared/DC/Scripts/Bindings.py", line 361, in _bindAndExec
return self._exec(bound_data, args, kw)
File "/usr/local/lib/python/site-packages/Products.CMFCore-2.2.4-py2.7.egg/Products/CMFCore/FSPageTemplate.py", line 240, in _exec
result = self.pt_render(extra_context=bound_names)
File "/usr/local/lib/python/site-packages/Products.CMFCore-2.2.4-py2.7.egg/Products/CMFCore/FSPageTemplate.py", line 180, in pt_render
self, source, extra_context
File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Products/PageTemplates/PageTemplate.py", line 80, in pt_render
showtal=showtal)
File "/usr/local/lib/python/site-packages/zope.pagetemplate-3.5.2-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/usr/local/lib/python/site-packages/five.pt-2.1.2-py2.7.egg/five/pt/patches.py", line 127, in call
result = self.template.render(**context)
File "/usr/local/lib/python/site-packages/z3c.pt-2.0-py2.7.egg/z3c/pt/pagetemplate.py", line 118, in render
return base_renderer(**context)
File "/usr/local/lib/python/site-packages/Chameleon-2.0-py2.7.egg/chameleon/zpt/template.py", line 107, in render
return super(PageTemplate, self).render(**k)
File "/usr/local/lib/python/site-packages/Chameleon-2.0-py2.7.egg/chameleon/template.py", line 183, in render
raise_with_traceback(exc, tb)
File "/usr/local/lib/python/site-packages/Chameleon-2.0-py2.7.egg/chameleon/template.py", line 167, in render
self._render(stream, econtext, rcontext)
File "/tmp/tmpP8xWU3/db28e1f8470b8e0b414e8d07498c64644bca4211.py", line 2079, in render
__macro.include(__stream, econtext.copy(), rcontext)
File "/tmp/tmpP8xWU3/182e39a889e4b8a1b7a65b6822d7107dd61a0782.py", line 1263, in render_master
__value = _static_219137548(getitem('portal_state'), getitem('request'), True, 'language')
File "/usr/local/lib/python/site-packages/five.pt-2.1.2-py2.7.egg/five/pt/expressions.py", line 113, in call
base, name, path_items[i:], request=request)
File "/usr/local/lib/python/site-packages/zope.traversing-3.7.1-py2.7.egg/zope/traversing/adapters.py", line 139, in traversePathElement
return traversable.traverse(nm, further_path)
- traceback_info: (None, 'language')
File "/usr/local/lib/python/site-packages/zope.traversing-3.7.1-py2.7.egg/zope/traversing/adapters.py", line 53, in traverse
raise LocationError(subject, name)
- traceback_info: (None, 'language', ())
RenderError: An uncaught exception was raised.

LocationError: (None, 'language')

 - Expression: "portal_state/language"
 - Filename:   <string>
 - Location:   (10:10)
 - Arguments:  __slot_content_core: <list - at 0xe27cf8c>
               repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper folder_summary_view at 0xdfb3d9c>
               exists: <instancemethod evaluate_exists at 0xcfb1d9c>
               modules: <instance - at 0xa9f8a6c>
               here: <instance - at 0xdd87d4c>
               user: <ImplicitAcquisitionWrapper - at 0xdfb3e8c>
               nothing: <NoneType - at 0x81904d8>
               path: <instancemethod evaluate_path at 0xcfb1b1c>
               traverse_subpath: <list - at 0xdfa7d4c>
               convert: <function translate at 0xdfb4d84>
               container: <ImplicitAcquisitionWrapper plone at 0xdfb32fc>
               default: <object - at 0xb77ff678L>
               __error__: <list - at 0xe59704c>
               request: <instance - at 0xdfb0dec>
               wrapped_repeat: <SafeMapping - at 0xe2ba324>
               decode: <function decode at 0xdfb4dbc>
               macros: <Macros - at 0xe3a7a1c>
               context: <instance - at 0xdd87d4c>
               translate: <function translate at 0xdfb4d84>
               root: <ImplicitAcquisitionWrapper Zope at 0xdfb352c>
               options: {...} (1)
               loop: {...} (0)

It seems thaat portal_state is not available as a variable as it is without five.pt

debug mode atexit breaks tests, probably leaks

When running the deform tests, during the atexit handler registered under debug mode:

FAILED (errors=2)
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/chrism/opt/Python-2.6.5/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 85, in cleanup
    shutil.rmtree(path)
AttributeError: 'NoneType' object has no attribute 'rmtree'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/home/chrism/opt/Python-2.6.5/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 85, in cleanup
    shutil.rmtree(path)
AttributeError: 'NoneType' object has no attribute 'rmtree'

No such file or directory error with Plone image_view_fullscreen

Traceback

Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 204, in _exec
  Module Products.CMFCore.FSObject, line 183, in _updateFromFS
  Module Products.CMFCore.FSPageTemplate, line 146, in _readFile
  Module zope.pagetemplate.pagetemplate, line 143, in write
  Module five.pt.patches, line 83, in cook
  Module z3c.pt.pagetemplate, line 209, in __init__
  Module chameleon.zpt.template, line 66, in __init__
  Module chameleon.template, line 252, in __init__
OSError: [Errno 2] No such file or directory: '/usr/local/plone/buildout-cache/eggs/five.pt-2.1.3-py2.6.egg/five/pt/leadImage-1.jpg'

Steps to reproduce

  • Start with a Plone 4.1 instance using Chameleon
  • Create new site
  • Add a News Item to the News folder, including an image
  • View the News Item
  • Click on the image in the news item view, which takes you to the image_view_fullscreen view. This gives the error above.

Notes

I verified this only happens with Chameleon enabled, and not with the default Plone 4.1

And, 22% increase in pages/second when tested with ab. Awesome!

SyntaxError: invalid syntax

Having moved beyond #22, my tests now fail with the following TB where they don't fail w/o five.pt:

    browser.getLink(url='createObject?type_name=Department').click()
Exception raised:
    Traceback (most recent call last):
      File "/home/xen/src/python/parts/opt/lib/python2.7/doctest.py", line 1254, in **run
        compileflags, 1) in test.globs
      File "<doctest README.txt[41]>", line 1, in <module>
        browser.getLink(url='createObject?type_name=Department').click()
      File "/usr/local/lib/python/site-packages/zope.testbrowser-3.6.0a2-py2.7.egg/zope/testbrowser/browser.py", line 435, in click
        self.browser.mech_browser.follow_link(self.mech_link)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_mechanize.py", line 575, in follow_link
        return self.open(self.click_link(link, *_kwds))
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_mechanize.py", line 209, in open
        return self._mech_open(url, data, timeout=timeout)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_mechanize.py", line 236, in _mech_open
        response = UserAgentBase.open(self, request, data)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_opener.py", line 202, in open
        response = meth(req, response)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_http.py", line 612, in http_response
        "http", request, response, code, msg, hdrs)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_opener.py", line 219, in error
        result = apply(self._call_chain, args)
      File "/home/xen/src/python/parts/opt/lib/python2.7/urllib2.py", line 372, in _call_chain
        result = func(_args)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_http.py", line 146, in http_error_302
        return self.parent.open(new)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_mechanize.py", line 209, in open
        return self._mech_open(url, data, timeout=timeout)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_mechanize.py", line 236, in _mech_open
        response = UserAgentBase.open(self, request, data)
      File "/usr/local/lib/python/site-packages/mechanize-0.1.11-py2.7.egg/mechanize/_opener.py", line 191, in open
        response = urlopen(self, req, data)
      File "/home/xen/src/python/parts/opt/lib/python2.7/urllib2.py", line 412, in _open
        '_open', req)
      File "/home/xen/src/python/parts/opt/lib/python2.7/urllib2.py", line 372, in _call_chain
        result = func(_args)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Products/Five/testbrowser.py", line 85, in http_open
        return self.do_open(PublisherConnection, req)
      File "/home/xen/src/python/parts/opt/lib/python2.7/urllib2.py", line 1168, in do_open
        h.request(req.get_method(), req.get_selector(), req.data, headers)
      File "/usr/local/lib/python/site-packages/zope.testbrowser-3.6.0a2-py2.7.egg/zope/testbrowser/testing.py", line 82, in request
        self.response = self.caller(request_string, handle_errors)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Testing/ZopeTestCase/functional.py", line 40, in wrapped_func
        return func(_args, **kw)
      File "/home/xen/src/work/ovt.buildout/src/collective.testcaselayer/src/collective/testcaselayer/functional.py", line 102, in http
        debug=not handle_errors,
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/Test.py", line 204, in publish_module
        response = publish(request, module_name, after_list, debug=debug)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/Publish.py", line 127, in publish
        request, bind=1)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/mapply.py", line 77, in mapply
        if debug is not None: return debug(object,args,context)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/Publish.py", line 47, in call_object
        result=apply(object,args) # Type s<cr> to step into published object.
      File "/usr/local/lib/python/site-packages/Plone-4.0.7-py2.7.egg/Products/CMFPlone/FactoryTool.py", line 446, in __call**
        self.REQUEST, bind=1)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/mapply.py", line 77, in mapply
        if debug is not None: return debug(object,args,context)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/ZPublisher/Publish.py", line 47, in call_object
        result=apply(object,args) # Type s<cr> to step into published object.
      File "/usr/local/lib/python/site-packages/Products.CMFFormController-3.0.1-py2.7.egg/Products/CMFFormController/FSControllerPageTemplate.py", line 91, in **call**
        return self._call(FSControllerPageTemplate.inheritedAttribute('__call__'), _args, *_kwargs)
      File "/usr/local/lib/python/site-packages/Products.CMFFormController-3.0.1-py2.7.egg/Products/CMFFormController/BaseControllerPageTemplate.py", line 31, in _call
        return inherited_call(self, _args, *_kwargs)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Shared/DC/Scripts/Bindings.py", line 324, in __call__
        return self._bindAndExec(args, kw, None)
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Shared/DC/Scripts/Bindings.py", line 361, in _bindAndExec
        return self._exec(bound_data, args, kw)
      File "/usr/local/lib/python/site-packages/Products.CMFCore-2.2.4-py2.7.egg/Products/CMFCore/FSPageTemplate.py", line 240, in _exec
        result = self.pt_render(extra_context=bound_names)
      File "/usr/local/lib/python/site-packages/Products.CMFCore-2.2.4-py2.7.egg/Products/CMFCore/FSPageTemplate.py", line 180, in pt_render
        self, source, extra_context
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Products/PageTemplates/PageTemplate.py", line 80, in pt_render
        showtal=showtal)
      File "/usr/local/lib/python/site-packages/zope.pagetemplate-3.5.2-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
        strictinsert=0, sourceAnnotations=sourceAnnotations)()
      File "/usr/local/lib/python/site-packages/five.pt-2.1.3-py2.7.egg/five/pt/patches.py", line 127, in __call__
        result = self.template.render(**context)
      File "/usr/local/lib/python/site-packages/z3c.pt-2.0-py2.7.egg/z3c/pt/pagetemplate.py", line 118, in render
        return base_renderer(**context)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/zpt/template.py", line 111, in render
        return super(PageTemplate, self).render(*_k)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/template.py", line 186, in render
        raise_with_traceback(exc, tb)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/template.py", line 168, in render
        self._render(stream, econtext, rcontext)
      File "/tmp/tmp6lDEDQ/9774bf78f507f328ac578f24f3e24cf60f248435.py", line 32, in render
        __macro.include(__stream, econtext.copy(), rcontext)
      File "/tmp/tmp6lDEDQ/1b8dad8db196218fc4e2b482aed898af830b2d2d.py", line 933, in render_master
        __macro.include(__stream, econtext.copy(), rcontext)
      File "/tmp/tmp6lDEDQ/b702df93603eb82ac2a9fa5d39e7da4a45cf66cd.py", line 2392, in render_master
        render_content(__stream, econtext.copy(), rcontext)
      File "/tmp/tmp6lDEDQ/b702df93603eb82ac2a9fa5d39e7da4a45cf66cd.py", line 1007, in render_content
        __slot_main(__stream, econtext.copy(), rcontext)
      File "/tmp/tmp6lDEDQ/1b8dad8db196218fc4e2b482aed898af830b2d2d.py", line 914, in __fill_main
        render_main(__stream, econtext.copy(), rcontext)
      File "/tmp/tmp6lDEDQ/1b8dad8db196218fc4e2b482aed898af830b2d2d.py", line 70, in render_main
        __macro.include(__stream, econtext.copy(), rcontext)
      File "/tmp/tmp6lDEDQ/e02593e1851a4c3bca305c5896b0f37ae20592a0.py", line 624, in render_body
        __macro = _guarded_getattr(getitem('context'), 'widget')(_guarded_getattr(getitem('field'), 'getName')(), mode='edit')
      File "/usr/local/lib/python/site-packages/Products.Archetypes-1.6.6-py2.7.egg/Products/Archetypes/BaseObject.py", line 284, in widget
        *_kwargs)
      File "/usr/local/lib/python/site-packages/Products.Archetypes-1.6.6-py2.7.egg/Products/Archetypes/Renderer.py", line 24, in render
        result = widget(mode, instance, context)
      File "/usr/local/lib/python/site-packages/Products.Archetypes-1.6.6-py2.7.egg/Products/Archetypes/generator/widget.py", line 140, in **call**
        return template.macros[mode]
      File "/usr/local/lib/python/site-packages/Zope2-2.12.19-py2.7-linux-i686.egg/Products/PageTemplates/PageTemplate.py", line 52, in macros
        return self.pt_macros()
      File "/usr/local/lib/python/site-packages/Products.CMFCore-2.2.4-py2.7.egg/Products/CMFCore/FSPageTemplate.py", line 167, in pt_macros
        self._updateFromFS()
      File "/usr/local/lib/python/site-packages/Products.CMFCore-2.2.4-py2.7.egg/Products/CMFCore/FSObject.py", line 183, in _updateFromFS
        self._readFile(1)
      File "/usr/local/lib/python/site-packages/Products.CMFCore-2.2.4-py2.7.egg/Products/CMFCore/FSPageTemplate.py", line 146, in _readFile
        self.write(data)
      File "/usr/local/lib/python/site-packages/zope.pagetemplate-3.5.2-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 143, in write
        self._cook()
      File "/usr/local/lib/python/site-packages/five.pt-2.1.3-py2.7.egg/five/pt/patches.py", line 78, in cook
        encoding='utf-8')
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/zpt/template.py", line 66, in __init__
        super(PageTemplate, self).**init**(_args, *_kwargs)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/template.py", line 117, in **init**
        self.cook(body)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/template.py", line 142, in cook
        program = self._cook(body, digest)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/template.py", line 212, in _cook
        self.loader.build(source, filename)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/loader.py", line 114, in build
        return self._load(base, name)
      File "/usr/local/lib/python/site-packages/Chameleon-2.0.1-py2.7.egg/chameleon/loader.py", line 126, in _load
        module = imp.load_source(base, filename, f)
    SyntaxError: An uncaught exception was raised.

File "/tmp/tmp6lDEDQ/db3180c52df5556462187f20f7f18c48d0e783d3.py", line 2839

__value = _guarded_getattr(getitem('refs'), 'sort')((lambda getitem('x'), getitem('y'): get('cmp', cmp)(_guarded_getattr(getitem('x'), 'order'), _guarded_getattr(getitem('y'), 'order'))))

                                                                   ^

SyntaxError: invalid syntax

  • Expression: "python:context.widget(field.getName(), mode='edit')"
  • Filename:
  • Location: (103:49)
  • Arguments: repeat: {...} (0)
    template: <ImplicitAcquisitionWrapper atct_edit at 0xfb63b6c>
    exists: <instancemethod evaluate_exists at 0x113e6d24>
    modules: <instance - at 0x9628bcc>
    here: <ImplicitAcquisitionWrapper department.2011-07-22.0950229220 at 0xfd59874>
    user: <ImplicitAcquisitionWrapper - at 0x10467c5c>
    nothing: <NoneType - at 0x81904d8>
    path: <instancemethod evaluate_path at 0xfc2df7c>
    traverse_subpath: <list - at 0x1115928c>
    convert: <function translate at 0xfb776bc>
    container: <ImplicitAcquisitionWrapper plone at 0x10276f2c>
    default: <object - at 0xb77df678L>
    error: <list - at 0x1102e28c>
    request: <instance - at 0x1111978c>
    wrapped_repeat: <SafeMapping - at 0x111708c4>
    decode: <function decode at 0xfb77f0c>
    macros: <Macros - at 0xc6fc35c>
    context: <ImplicitAcquisitionWrapper department.2011-07-22.0950229220 at 0xfd59874>
    translate: <function translate at 0xfb776bc>
    root: <ImplicitAcquisitionWrapper Zope at 0xf999eb4>
    options: {...} (2)
    loop: {...} (4)

LocationError: (<type 'type'>, 'name')

Plone4.1, chameleon-2.3.3, z3c.pt 2.1.1, five.pt 2.1.5

how to reproduce: Create new "Collection" content, then click on "Criteria" tab

Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 91, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 31, in _call
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 240, in _exec
  Module Products.CMFCore.FSPageTemplate, line 180, in pt_render
  Module Products.PageTemplates.PageTemplate, line 79, in pt_render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module five.pt.patches, line 129, in __call__
  Module z3c.pt.pagetemplate, line 126, in render
  Module chameleon.zpt.template, line 123, in render
  Module chameleon.template, line 211, in render
  Module chameleon.template, line 188, in render
  Module ac23f70b3d168c68e450aafe7e5224d91d7fd636.py, line 3329, in render
  Module 678b3370d405bbb7754cefd67a1706cdff0836fc.py, line 2614, in render_master
  Module 678b3370d405bbb7754cefd67a1706cdff0836fc.py, line 1103, in render_content
  Module ac23f70b3d168c68e450aafe7e5224d91d7fd636.py, line 2069, in __fill_main
  Module five.pt.expressions, line 115, in __call__
  Module five.pt.expressions, line 109, in traverse
  Module zope.traversing.adapters, line 136, in traversePathElement
   - __traceback_info__: (<type 'type'>, 'name')
  Module zope.traversing.adapters, line 50, in traverse
   - __traceback_info__: (<type 'type'>, 'name', ())
LocationError: (<type 'type'>, 'name')

 - Expression: "type/name"
 - Filename:   file:/home/fafhrd/dev/plone/plone4.1-base/eggs/Products.ATContentTypes-2.1.3-py2.6.egg/Products/ATContentTypes/skins/ATContentTypes/criterion_edit_form.cpt
 - Location:   (196:63)
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper criterion_edit_form at 0xc774464>
               modules: <instance - at 0xa447eac>
               here: <ImplicitAcquisitionWrapper test at 0xc7748c4>
               user: <ImplicitAcquisitionWrapper - at 0xc774d74>
               nothing: <NoneType - at 0x823c0b8>
               traverse_subpath: <list - at 0xd0b470c>
               convert: <function translate at 0xd2bfdf4>
               container: <ImplicitAcquisitionWrapper Plone at 0xc0aa9b4>
               default: <object - at 0xb73f3688L>
               request: <instance - at 0xcc3c68c>
               wrapped_repeat: <SafeMapping - at 0xc77466c>
               decode: <function decode at 0xd2bf0d4>
               context: <ImplicitAcquisitionWrapper test at 0xc7748c4>
               translate: <function translate at 0xd2bfdf4>
               root: <ImplicitAcquisitionWrapper Zope at 0xbee07fc>
               options: {...} (2)
               loop: {...} (3)

modules expressions only have already imported modules

The modules available in TAL expressions only contain already imported modules while the reference implementation will import modules that aren't yet in sys.modules. Here's the TB I get under Chameleon that I don't get without::

KeyError: 'webcouturier.dropdownmenu.utils'

 - Expression: "python:modules['webcouturier.dropdownmenu.utils']"
 - Filename:   .../src/webcouturier.dropdownmenu/webcouturier/dropdownmenu/browser/dropdown_recurse.pt
 - Location:   (9:22)

 - Source:     ... e="utils python:modules['webcouturier.dropdownmenu.utils'];
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               context: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               views: <ViewMapper - at 0xe326ecc>
               modules: <instance - at 0xa50feec>
               bottomLevel: 0
               args: <tuple - at 0xb77ea02cL>
               here: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               user: <ImplicitAcquisitionWrapper - at 0xe6b1a7c>
               nothing: <NoneType - at 0x81904d8>
               children: <list - at 0xf0b7acc>
               traverse_subpath: <list - at 0xe504f2c>
               convert: <function translate at 0xf28172c>
               container: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               normalizeString: <instancemethod normalizeString at 0xf2ee5cc>
               level: 1
               default: <object - at 0xb78096f0L>
               request: <instance - at 0xe849bac>
               wrapped_repeat: <SafeMapping - at 0xf2ee194>
               decode: <function decode at 0xf28164c>
               template: <ViewPageTemplateFile - at 0xcf2114c>
               translate: <function translate at 0xf28172c>
               root: <ImplicitAcquisitionWrapper Zope at 0xce4beb4>
               options: {...} (3)
               loop: {...} (0)
               view: <DropdownMenuViewlet plone.global_sections at 0xe87a2cc>

 - Expression: "python:view.getTabObject(tabUrl = tab['url'], tabPath = tab.get('path'))"
 - Filename:   .../src/webcouturier.dropdownmenu/webcouturier/dropdownmenu/browser/dropdown_sections.pt
 - Location:   (9:43)

 - Source:     ... python:view.getTabObject(tabUrl = tab['url'], tabPath = tab.get('path')) ...
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               context: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               views: <ViewMapper - at 0xd46af4c>
               modules: <instance - at 0xa50feec>
               args: <tuple - at 0xb77ea02cL>
               here: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               user: <ImplicitAcquisitionWrapper - at 0xe6b1a7c>
               tab: {...} (4)
               nothing: <NoneType - at 0x81904d8>
               traverse_subpath: <list - at 0xe9aa44c>
               convert: <function translate at 0xf2818ec>
               container: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               default: <object - at 0xb78096f0L>
               request: <instance - at 0xe849bac>
               wrapped_repeat: <SafeMapping - at 0xf27ed24>
               decode: <function decode at 0xf281924>
               template: <ViewPageTemplateFile - at 0xcf2110c>
               view: <DropdownMenuViewlet plone.global_sections at 0xe87a2cc>
               translate: <function translate at 0xf2818ec>
               root: <ImplicitAcquisitionWrapper Zope at 0xce4beb4>
               options: {...} (0)
               loop: {...} (1)
               attrs: {...} (1)

 - Expression: "provider:plone.portalheader"
 - Filename:   /usr/local/lib/python/site-packages/plone.app.layout-2.1.8-py2.7.egg/plone/app/layout/viewlets/portal_header.pt
 - Location:   (2:32)

 - Source:     ... :replace="structure provider:plone.portalheader" />
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               context: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               views: <ViewMapper - at 0xea2c6ac>
               modules: <instance - at 0xa50feec>
               args: <tuple - at 0xb77ea02cL>
               here: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               user: <ImplicitAcquisitionWrapper - at 0xe6b1a7c>
               nothing: <NoneType - at 0x81904d8>
               traverse_subpath: <list - at 0xe2c934c>
               convert: <function translate at 0xf473df4>
               container: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               default: <Placeholder - at 0xd80984c>
               request: <instance - at 0xe849bac>
               wrapped_repeat: <SafeMapping - at 0xf040e3c>
               decode: <function decode at 0xf473e2c>
               template: <ViewPageTemplateFile - at 0xcb4152c>
               view: <SimpleViewletClass from /usr/local/lib/python/site-packages/plone.app.layout-2.1.8-py2.7.egg/plone/app/layout/viewlets/portal_header.pt plone.header at 0xe9ae86c>
               translate: <function translate at 0xf473df4>
               root: <ImplicitAcquisitionWrapper Zope at 0xce4beb4>
               options: {...} (0)
               loop: {...} (0)
               attrs: {...} (1)

 - Expression: "provider:plone.portaltop"
 - Filename:   <string>
 - Location:   (68:40)
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper folder_listing at 0xe309824>
               modules: <instance - at 0xa50feec>
               here: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               user: <ImplicitAcquisitionWrapper - at 0xe6b1a7c>
               nothing: <NoneType - at 0x81904d8>
               traverse_subpath: <list - at 0xea290ac>
               convert: <function translate at 0xf28d844>
               container: <ImplicitAcquisitionWrapper plone at 0xf268644>
               default: <object - at 0xb78096f0L>
               request: <instance - at 0xe849bac>
               wrapped_repeat: <SafeMapping - at 0xe6b1f04>
               decode: <function decode at 0xf28de64>
               context: <ImplicitAcquisitionWrapper departments at 0xf2685a4>
               translate: <function translate at 0xf28d844>
               root: <ImplicitAcquisitionWrapper Zope at 0xce4beb4>
               options: {...} (1)
               loop: {...} (0)

For example, this works fine under chameleon if I just do "import webcouturier.dropdownmenu.utils" sometime before the template is rendered.

More fun with selected/disabled attributes

After updating to the latest Chameleon (2.3.8) some TAL attribute constructs no longer work. Two examples:

<option tal:attributes="value task/UID; selected python: last_task == path('task/UID')"
    tal:content="python:task.Title">task title</option>

results in:

<option selected=​"True" value=​"foo">​bar​</option>​
<option selected=​"False" value=​"spam">​eggs​</option>​

Instead of dropping the attribute and emitting selected=​"selected".

A similar problem exists for "disabled", as in:

 <option tal:attributes="value item/getURL|default;
      disabled python:not item.get('getURL')">
      text
 </option>

which always results in:

<option value="" disabled="True">
    text
</option>

where the attribute should be dropped.

no idea for a title : I cannot make a sense to the traceback :(

I've got a lot different instances of a customized folder and only some give me headaches...
I've a folder named resultats where the results of a search on the website is shown ( I choosed a view of a folder to have the opportunity to have a portlet.)
sure, but what is this file ?
Filename: /spirulinea/site/public/resultats/products.cmfcore.interfaces._content.icontentish-collective.disqus

2011-09-17 19:23:46 ERROR root Exception while rendering an error message
Traceback (most recent call last):
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/OFS/SimpleItem.py", line 241, in raise_standardErrorMessage
v = s(**kwargs)
File "/home/plone/Plone/buildout-cache/eggs/Products.CMFCore-2.2.4-py2.6.egg/Products/CMFCore/FSPythonScript.py", line 129, in call
return Script.call(self, _args, *_kw)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 322, in call
return self._bindAndExec(args, kw, None)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 359, in _bindAndExec
return self._exec(bound_data, args, kw)
File "/home/plone/Plone/buildout-cache/eggs/Products.PythonScripts-2.13.0-py2.6.egg/Products/PythonScripts/PythonScript.py", line 344, in _exec
result = f(_args, *_kw)
File "Script (Python)", line 34, in standard_error_message
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 322, in call
return self._bindAndExec(args, kw, None)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 359, in _bindAndExec
return self._exec(bound_data, args, kw)
File "/home/plone/Plone/buildout-cache/eggs/Products.CMFCore-2.2.4-py2.6.egg/Products/CMFCore/FSPageTemplate.py", line 240, in _exec
result = self.pt_render(extra_context=bound_names)
File "/home/plone/Plone/buildout-cache/eggs/Products.CMFCore-2.2.4-py2.6.egg/Products/CMFCore/FSPageTemplate.py", line 180, in pt_render
self, source, extra_context
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/PageTemplate.py", line 79, in pt_render
showtal=showtal)
File "/home/plone/Plone/buildout-cache/eggs/zope.pagetemplate-3.5.2-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/home/plone/Plone/buildout-cache/eggs/five.pt-2.1.5-py2.6.egg/five/pt/patches.py", line 129, in call
result = self.template.render(**context)
File "/home/plone/Plone/buildout-cache/eggs/z3c.pt-2.1.1-py2.6.egg/z3c/pt/pagetemplate.py", line 126, in render
return base_renderer(**context)
File "/home/plone/Plone/buildout-cache/eggs/Chameleon-2.3.6-py2.6.egg/chameleon/zpt/template.py", line 156, in render
return super(PageTemplate, self).render(**vars)
File "/home/plone/Plone/buildout-cache/eggs/Chameleon-2.3.6-py2.6.egg/chameleon/template.py", line 211, in render
raise_with_traceback(exc, tb)
File "/home/plone/Plone/buildout-cache/eggs/Chameleon-2.3.6-py2.6.egg/chameleon/template.py", line 188, in render
self._render(stream, econtext, rcontext)
File "637889f1c1e36d251ff5d3027296dd6a3bf07ca2.py", line 2956, in render
File "c4d6083fd4627b0058bebdfd8252b4a8e3bb2839.py", line 2120, in render_master
File "/home/plone/Plone/buildout-cache/eggs/five.pt-2.1.5-py2.6.egg/five/pt/expressions.py", line 179, in call
return cp.render()
File "/home/plone/Plone/buildout-cache/eggs/plone.app.viewletmanager-2.0.2-py2.6.egg/plone/app/viewletmanager/manager.py", line 154, in render
return BaseOrderedViewletManager.render(self)
File "/home/plone/Plone/buildout-cache/eggs/plone.app.viewletmanager-2.0.2-py2.6.egg/plone/app/viewletmanager/manager.py", line 85, in render
return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
File "/home/plone/Plone/buildout-cache/eggs/five.customerize-1.0.1-py2.6.egg/five/customerize/zpt.py", line 143, in render
return template._exec(bound_names, args, kwargs)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/ZopePageTemplate.py", line 334, in _exec
result = self.pt_render(extra_context=bound_names)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/ZopePageTemplate.py", line 431, in pt_render
result = PageTemplate.pt_render(self, source, extra_context)
File "/home/plone/Plone/buildout-cache/eggs/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/PageTemplate.py", line 79, in pt_render
showtal=showtal)
File "/home/plone/Plone/buildout-cache/eggs/zope.pagetemplate-3.5.2-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/home/plone/Plone/buildout-cache/eggs/five.pt-2.1.5-py2.6.egg/five/pt/patches.py", line 129, in call
result = self.template.render(**context)
File "/home/plone/Plone/buildout-cache/eggs/z3c.pt-2.1.1-py2.6.egg/z3c/pt/pagetemplate.py", line 126, in render
return base_renderer(**context)
File "/home/plone/Plone/buildout-cache/eggs/Chameleon-2.3.6-py2.6.egg/chameleon/zpt/template.py", line 156, in render
return super(PageTemplate, self).render(**vars)
File "/home/plone/Plone/buildout-cache/eggs/Chameleon-2.3.6-py2.6.egg/chameleon/template.py", line 211, in render
raise_with_traceback(exc, tb)
File "/home/plone/Plone/buildout-cache/eggs/Chameleon-2.3.6-py2.6.egg/chameleon/template.py", line 188, in render
self._render(stream, econtext, rcontext)
File "73e1aab90e65b93051ccd3ead1762b6c60374d79.py", line 38, in render
Unauthorized: You are not allowed to access 'forum_id' in this context

  • Expression: "python: view.is_discussion_allowed and view.settings.forum_id"
  • Filename: /spirulinea/site/public/resultats/products.cmfcore.interfaces._content.icontentish-collective.disqus
  • Location: (2:20)
  • Arguments: repeat: {...} (0)
    template: <ImplicitAcquisitionWrapper products.cmfcore.interfaces._content.icontentish-collective.disqus at 0xed86374>
    modules: <instance - at 0x9ef79cc>
    here: <ImplicitAcquisitionWrapper spiruline-securite-deux-mots at 0xfba261c>
    user: <ImplicitAcquisitionWrapper - at 0x10d6b52c>
    nothing: <NoneType - at 0x82301b8>
    convert: <function translate at 0xfe5b6bc>
    container: <ImplicitAcquisitionWrapper spiruline-securite-deux-mots at 0xfba261c>
    default: <object - at 0xb73cb698L>
    request: <instance - at 0x10d4dcec>
    wrapped_repeat: <SafeMapping - at 0x1036a16c>
    decode: <function decode at 0xfe5bdf4>
    context: <ImplicitAcquisitionWrapper spiruline-securite-deux-mots at 0xfba261c>
    translate: <function translate at 0xfe5b6bc>
    root: <ImplicitAcquisitionWrapper Zope at 0x10d036bc>
    options: {...} (1)
    loop: {...} (0)
    view: <TTWViewlet None at 0xfe5474c>
  • Expression: "provider:plone.belowcontent"
  • Filename: file:/home/plone/Plone/buildout-cache/eggs/plonetheme.sunburst-1.2-py2.6.egg/plonetheme/sunburst/skins/sunburst_templates/main_template.pt
  • Location: (134:67)
  • Arguments: repeat: {...} (0)
    template: <ImplicitAcquisitionWrapper default_error_message at 0x1035bacc>
    modules: <instance - at 0x9ef79cc>
    here: <ImplicitAcquisitionWrapper spiruline-securite-deux-mots at 0xfba261c>
    user: <ImplicitAcquisitionWrapper - at 0x10d6b52c>
    nothing: <NoneType - at 0x82301b8>
    traverse_subpath: <list - at 0x101f3f8c>
    convert: <function translate at 0xfe5b7d4>
    container: <ImplicitAcquisitionWrapper spiruline-securite-deux-mots at 0xfba261c>
    default: <object - at 0xb73cb698L>
    request: <instance - at 0x10d4dcec>
    wrapped_repeat: <SafeMapping - at 0x1035ba7c>
    decode: <function decode at 0xfe5b48c>
    context: <ImplicitAcquisitionWrapper spiruline-securite-deux-mots at 0xfba261c>
    translate: <function translate at 0xfe5b7d4>
    root: <ImplicitAcquisitionWrapper Zope at 0x10d036bc>
    options: {...} (9)
    loop: {...} (1)

chameleon incorrectly tries to parse $ vars in text

it seems that chameleon tries to parse text as a variable which is actually not a variable, like $name in a construct like:

<div class="formHelp" i18n:translate="help_parameter_expressions">
    refer to a parameter by <code>$name</code>. Parameters
</div>

this is the case with plone.app.theming's controlpanel in https://svn.plone.org/svn/plone/plone.app.theming/trunk/src/plone/app/theming/browser/controlpanel.pt, line 265, column 55.

i got this traceback:

2011-07-21 17:54:13 ERROR Zope.SiteErrorLog 1311263653.560.501985316358 http://localhost:8080/g24/@@theming-controlpanel
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module plone.app.theming.browser.controlpanel, line 36, in __call__
  Module Products.Five.browser.pagetemplatefile, line 125, in __call__
  Module Products.Five.browser.pagetemplatefile, line 59, in __call__
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module five.pt.patches, line 127, in __call__
  Module z3c.pt.pagetemplate, line 118, in render
  Module chameleon.zpt.template, line 107, in render
  Module chameleon.template, line 167, in render
  Module controlpanel_f1c1a3e882c2597ae2ca97f39b8626ac0b234ae8, line 6307, in render
  Module e66da8b7fb7861e0dbe5431d7f1d4d35dca3bca3, line 302, in render_master
  Module a7c28bb6cca4cd87571651e62cefc41c8672572d, line 2395, in render_master
  Module e66da8b7fb7861e0dbe5431d7f1d4d35dca3bca3, line 273, in __fill_content
  Module a7c28bb6cca4cd87571651e62cefc41c8672572d, line 1033, in render_content
  Module e66da8b7fb7861e0dbe5431d7f1d4d35dca3bca3, line 255, in __fill_main
  Module controlpanel_f1c1a3e882c2597ae2ca97f39b8626ac0b234ae8, line 3534, in __fill_prefs_configlet_main
  Module chameleon.utils, line 228, in __getitem__
NameError: name

where the compiled template around 3534 reads:

        # <Expression u'name' (264:55)> -> __content_141865920
        try:
            __content_141865920 = _static_183635180(getitem('name'), getitem('request'), True)
        except:
            rcontext.setdefault('__error__', []).append((u'name', 264, 55, '/home/thet/.buildout/eggs/plone.app.theming-1.0b8-py2.6.egg/plone/app/theming/browser/controlpanel.pt', _sys.exc_info()[1], ))
            raise

Can't parse UTF-8 template files

Template files with non ascii characters encoded in UTF-8 work fine with Zope's default implementation but not with Chameleon

e.g. The following causes a UnicodeDecodeError with Chameleon but works fine with Zope's default implementation. Note the mdash in the title element.

<?xml version="1.0" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>my title — my site</title></head>
<body></body>
</html>

Deform functional testing locates numerous errors

Install any Java interpreter.

Download and unpack http://code.google.com/p/selenium/downloads/detail?name=selenium-remote-control-1.0.3.zip&can=2&q=

Start three consoles:

console 1:
java -jar selenium-server.jar

console 2:
cd /path/to/deform/deformdemo
paster serve demo.ini

console 3:
cd /path/to/deform/deformdemo
python test.py

It will fire up Firefox and give you something like this result on the console upon which you ran "python test.py" and some tracebacks on the server console. These errors do not occur using Chameleon 1.

[chrism@thinko deform]$ env26/bin/python deformdemo/test.py
.FF..........................F...F.....F.F................FFFFFFFFF.FFF.FE...............FF..........FF.FFFFF.FFFF..FF.F.FFFFEFF.FFF.FF.F.F........................
======================================================================
ERROR: test_it (__main__.MultipleErrorMessagesInSequenceTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 2382, in test_it
    self.assertEqual(browser.get_text('error-deformField3'), 'Error 1')
  File "/home/chrism/projects/deform/deformdemo/selenium.py", line 1189, in get_text
    return self.get_string("getText", [locator,])
  File "/home/chrism/projects/deform/deformdemo/selenium.py", line 219, in get_string
    result = self.do_command(verb, args)
  File "/home/chrism/projects/deform/deformdemo/selenium.py", line 215, in do_command
    raise Exception, data
Exception: ERROR: Element error-deformField3 not found

======================================================================
ERROR: test_submit_none_added (__main__.SequenceOfMappingsWithInitialItem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1472, in test_submit_none_added
    self.assertEqual(browser.get_text('deformField1-addtext'),
  File "/home/chrism/projects/deform/deformdemo/selenium.py", line 1189, in get_text
    return self.get_string("getText", [locator,])
  File "/home/chrism/projects/deform/deformdemo/selenium.py", line 219, in get_string
    result = self.do_command(verb, args)
  File "/home/chrism/projects/deform/deformdemo/selenium.py", line 215, in do_command
    raise Exception, data
Exception: ERROR: Element deformField1-addtext not found

======================================================================
FAIL: test_submit_empty (__main__.AjaxFormTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 2257, in test_submit_empty
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_submit_invalid (__main__.AjaxFormTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 2275, in test_submit_invalid
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_submit_tooshort (__main__.CheckedPasswordWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 269, in test_submit_tooshort
    'Shorter than minimum length 5')
AssertionError: u'Shorter than minimum length ${min}' != 'Shorter than minimum length 5'

======================================================================
FAIL: test_submit_tooearly (__main__.DateInputWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 354, in test_submit_tooearly
    '2010-05-04 is earlier than earliest date 2010-05-05')
AssertionError: u'${val} is earlier than earliest date ${min}' != '2010-05-04 is earlier than earliest date 2010-05-05'

======================================================================
FAIL: test_submit_tooearly (__main__.DatePartsWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 439, in test_submit_tooearly
    '2008-01-01 is earlier than earliest date 2010-01-01')
AssertionError: u'${val} is earlier than earliest date ${min}' != '2008-01-01 is earlier than earliest date 2010-01-01'

======================================================================
FAIL: test_submit_empty (__main__.EditFormTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 490, in test_submit_empty
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 915, in test_render_default
    self.assertEqual(label, 'A number between 1 and 10*')
AssertionError: u'A number between ${min} and ${max}*' != 'A number between 1 and 10*'

======================================================================
FAIL: test_render_en (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 925, in test_render_en
    self.assertEqual(label, 'A number between 1 and 10*')
AssertionError: u'A number between ${min} and ${max}*' != 'A number between 1 and 10*'

======================================================================
FAIL: test_render_ru (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 935, in test_render_ru
    self.assertEqual(label, u'Число между 1 и 10*')
AssertionError: u'A number between ${min} and ${max}*' != u'\u0427\u0438\u0441\u043b\u043e \u043c\u0435\u0436\u0434\u0443 1 \u0438 10*'

======================================================================
FAIL: test_submit_empty_en (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 952, in test_submit_empty_en
    self.assertEqual(label, 'A number between 1 and 10*')
AssertionError: u'A number between ${min} and ${max}*' != 'A number between 1 and 10*'

======================================================================
FAIL: test_submit_empty_ru (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 968, in test_submit_empty_ru
    self.assertEqual(browser.get_text(error_node), u'требуется')
AssertionError: u'Required' != u'\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f'

======================================================================
FAIL: test_submit_toohigh_en (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1026, in test_submit_toohigh_en
    '11 is greater than maximum value 10')
AssertionError: u'${val} is greater than maximum value ${max}' != '11 is greater than maximum value 10'

======================================================================
FAIL: test_submit_toohigh_ru (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1046, in test_submit_toohigh_ru
    u'11 больше чем 10')
AssertionError: u'${val} is greater than maximum value ${max}' != u'11 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c 10'

======================================================================
FAIL: test_submit_toolow_en (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 987, in test_submit_toolow_en
    '0 is less than minimum value 1')
AssertionError: u'${val} is less than minimum value ${min}' != '0 is less than minimum value 1'

======================================================================
FAIL: test_submit_toolow_ru (__main__.InternationalizationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1007, in test_submit_toolow_ru
    u'0 меньше чем 1')
AssertionError: u'${val} is less than minimum value ${min}' != u'0 \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c 1'

======================================================================
FAIL: test_submit_empty (__main__.MappingWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 544, in test_submit_empty
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_submit_invalid_date (__main__.MappingWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 580, in test_submit_invalid_date
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_submit_invalid_number (__main__.MappingWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 560, in test_submit_invalid_number
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_it (__main__.MultipleErrorMessagesInMappingTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 2369, in test_it
    self.assertEqual(browser.get_text('error-deformField1'), 'Error 1')
AssertionError: u'Error ${num}' != 'Error 1'

======================================================================
FAIL: test_submit_empty (__main__.RedirectingAjaxFormTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 2257, in test_submit_empty
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_submit_invalid (__main__.RedirectingAjaxFormTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 2275, in test_submit_invalid
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.SequenceOfAutocompletes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1522, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Text')
AssertionError: u'Add ${subitem_title}' != 'Add Text'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfAutocompletes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1531, in test_submit_none_added
    'Add Text')
AssertionError: u'Add ${subitem_title}' != 'Add Text'

======================================================================
FAIL: test_submit_two_unfilled (__main__.SequenceOfAutocompletes)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1542, in test_submit_two_unfilled
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_add_and_remove (__main__.SequenceOfConstrainedLength)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1632, in test_add_and_remove
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Name')
AssertionError: u'Add ${subitem_title}' != 'Add Name'

======================================================================
FAIL: test_render_default (__main__.SequenceOfConstrainedLength)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1623, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Name')
AssertionError: u'Add ${subitem_title}' != 'Add Name'

======================================================================
FAIL: test_render_default (__main__.SequenceOfDateInputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1575, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Date')
AssertionError: u'Add ${subitem_title}' != 'Add Date'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfDateInputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1584, in test_submit_none_added
    'Add Date')
AssertionError: u'Add ${subitem_title}' != 'Add Date'

======================================================================
FAIL: test_submit_two_unfilled (__main__.SequenceOfDateInputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1595, in test_submit_two_unfilled
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.SequenceOfFileUploads)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1177, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'), 'Add Upload')
AssertionError: u'Add ${subitem_title}' != 'Add Upload'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfFileUploads)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1185, in test_submit_none_added
    self.assertEqual(browser.get_text('deformField1-addtext'), 'Add Upload')
AssertionError: u'Add ${subitem_title}' != 'Add Upload'

======================================================================
FAIL: test_submit_two_unfilled (__main__.SequenceOfFileUploads)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1196, in test_submit_two_unfilled
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.SequenceOfFileUploadsWithInitialItem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1302, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'), 'Add Upload')
AssertionError: u'Add ${subitem_title}' != 'Add Upload'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfFileUploadsWithInitialItem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1315, in test_submit_none_added
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.SequenceOfMappings)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1358, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Person')
AssertionError: u'Add ${subitem_title}' != 'Add Person'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfMappings)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1367, in test_submit_none_added
    'Add Person')
AssertionError: u'Add ${subitem_title}' != 'Add Person'

======================================================================
FAIL: test_submit_two_unfilled (__main__.SequenceOfMappings)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1378, in test_submit_two_unfilled
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.SequenceOfMappingsWithInitialItem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1459, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Person')
AssertionError: u'Add ${subitem_title}' != 'Add Person'

======================================================================
FAIL: test_submit_add_one (__main__.SequenceOfMappingsWithInitialItem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1492, in test_submit_add_one
    'Add Person')
AssertionError: u'Add ${subitem_title}' != 'Add Person'

======================================================================
FAIL: test_render_default (__main__.SequenceOfMaskedTextInputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1710, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Text')
AssertionError: u'Add ${subitem_title}' != 'Add Text'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfMaskedTextInputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1719, in test_submit_none_added
    'Add Text')
AssertionError: u'Add ${subitem_title}' != 'Add Text'

======================================================================
FAIL: test_submit_two_unfilled (__main__.SequenceOfMaskedTextInputs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1730, in test_submit_two_unfilled
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.SequenceOfRadioChoices)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1145, in test_render_default
    'Add Pepper Chooser')
AssertionError: u'Add ${subitem_title}' != 'Add Pepper Chooser'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfRadioChoices)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1154, in test_submit_none_added
    'Add Pepper Chooser')
AssertionError: u'Add ${subitem_title}' != 'Add Pepper Chooser'

======================================================================
FAIL: test_render_default (__main__.SequenceOfRichTextWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1664, in test_render_default
    self.assertEqual(browser.get_text('deformField1-addtext'),'Add Text')
AssertionError: u'Add ${subitem_title}' != 'Add Text'

======================================================================
FAIL: test_submit_none_added (__main__.SequenceOfRichTextWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1673, in test_submit_none_added
    'Add Text')
AssertionError: u'Add ${subitem_title}' != 'Add Text'

======================================================================
FAIL: test_submit_two_unfilled (__main__.SequenceOfRichTextWidgetTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 1684, in test_submit_two_unfilled
    self.failUnless(browser.is_element_present('css=.errorMsgLbl'))
AssertionError

======================================================================
FAIL: test_render_default (__main__.SequenceOfSequences)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "deformdemo/test.py", line 2018, in test_render_default
    'Add Names and Titles')
AssertionError: u'Add ${subitem_title}' != 'Add Names and Titles'

----------------------------------------------------------------------
Ran 163 tests in 77.391s

FAILED (failures=48, errors=2)
[chrism@thinko deform]$ 

Tracebacks

I see very circumspect traceback output when a Chameleon 2 template raises a traceback both in debug and non-debug mode. No indication in the traceback of where in the template the error occurs.

Non-debug-mode example:

======================================================================
ERROR: test_render_not_empty (deform.tests.test_functional.TestFunctional)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/chrism/projects/deform/deform/tests/test_functional.py", line 76, in test_render_not_empty
    html = form.render(appstruct)
  File "/home/chrism/projects/deform/deform/field.py", line 419, in render
    return self.serialize(cstruct, readonly=readonly)
  File "/home/chrism/projects/deform/deform/field.py", line 394, in serialize
    return self.widget.serialize(self, cstruct=cstruct, readonly=readonly)
  File "/home/chrism/projects/deform/deform/widget.py", line 791, in serialize
    null=null)
  File "/home/chrism/projects/deform/deform/template.py", line 119, in __call__
    return self.load(template_name)(**kw)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 106, in __call__
    return self.render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/zpt/template.py", line 94, in render
    return super(PageTemplate, self).render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 138, in render
    self._render(stream, econtext, kwargs)
  File "form_b53d3aca30cf830f0f639a7cb923b9c9899680d4.py", line 1067, in render
  File "/home/chrism/projects/deform/deform/template.py", line 119, in __call__
    return self.load(template_name)(**kw)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 106, in __call__
    return self.render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/zpt/template.py", line 94, in render
    return super(PageTemplate, self).render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 138, in render
    self._render(stream, econtext, kwargs)
  File "mapping_item_9376babeb2df15672442e2d9dcb87ad69da397e9.py", line 570, in render
AttributeError: 'NoneType' object has no attribute 'messages'

----------------------------------------------------------------------

Debug mode example:

======================================================================
ERROR: test_render_not_empty (deform.tests.test_functional.TestFunctional)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/chrism/projects/deform/deform/tests/test_functional.py", line 76, in test_render_not_empty
    html = form.render(appstruct)
  File "/home/chrism/projects/deform/deform/field.py", line 419, in render
    return self.serialize(cstruct, readonly=readonly)
  File "/home/chrism/projects/deform/deform/field.py", line 394, in serialize
    return self.widget.serialize(self, cstruct=cstruct, readonly=readonly)
  File "/home/chrism/projects/deform/deform/widget.py", line 791, in serialize
    null=null)
  File "/home/chrism/projects/deform/deform/template.py", line 119, in __call__
    return self.load(template_name)(**kw)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 106, in __call__
    return self.render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/zpt/template.py", line 94, in render
    return super(PageTemplate, self).render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 138, in render
    self._render(stream, econtext, kwargs)
  File "/tmp/tmpMvzKJL/form_b53d3aca30cf830f0f639a7cb923b9c9899680d4.py", line 1071, in render
    _cache_30403024 = getitem('rndr')(getitem('tmpl'), field=getitem('f'), cstruct=_lookup_attr(getitem('cstruct'), 'get')(_lookup_attr(getitem('f'), 'name'), getitem('null')))
  File "/home/chrism/projects/deform/deform/template.py", line 119, in __call__
    return self.load(template_name)(**kw)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 106, in __call__
    return self.render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/zpt/template.py", line 94, in render
    return super(PageTemplate, self).render(**kwargs)
  File "/home/chrism/projects/deform/env26/lib/python2.6/site-packages/Chameleon-2.0_rc2-py2.6.egg/chameleon/template.py", line 138, in render
    self._render(stream, econtext, kwargs)
  File "/tmp/tmpMvzKJL/mapping_item_9376babeb2df15672442e2d9dcb87ad69da397e9.py", line 573, in render
    _iterator = _lookup_attr(getitem('field'), 'error').messages()
AttributeError: 'NoneType' object has no attribute 'messages'

----------------------------------------------------------------------

"structure" expressions still escaping entities

I have the following failure under Chameleon that doesn't occur without:

Failed example:
    print msg
Differences (ndiff with -expected +actual):
      From: [email protected]
    - To: "Bar Contact Name" <[email protected]>
    ?                        ^           ^
    + To: "Bar Contact Name" &lt;[email protected]&gt;
    ?                        ^^^^           ^^^^

Here's the template snippet that this comes from:

From: <tal:from replace="structure view/from_" />

Here's the registration for the template:

<browser:page
   for=".interfaces.IContact"
   name="send_to_contact_email"
   permission="zope2.View"
   class=".send.SendEmail"
   template="send.pt"
   />

zope.traversing.interfaces.ITraversable violation

The ITraversable interface defines the the traverse method's furtherPath parameter as "a list of names still to be traversed. This method is allowed to change the contents of furtherPath."

However, when used in Plone 4.1 the furtherPath parameter is a tuple instead of a list which makes it impossible for the ITraversable implementation to modify it.

I noticed this when writing a view template for a Dexterity type that uses path traversal to render an image tag by traversing to a plone.namedfile image (e.g. @@images/image/thumb). The ITraversable implementation in plone.namedfile.scaling.ImageScaling attempts to .pop() the furtherPath which fails because it is a tuple.

Components used: Chameleon 2.4.4, z3c.pt 2.1.4, five.pt 2.1.5, Plone 4.1, plone.namedfile 1.0.4

Missing inheritance of i18n:domain to macros

As discussed on the plone-dev mailing list, I found one more problem with i18n.

One symptom I see is the "Save" and "Cancel" buttons in any Archetypes edit screens aren't translated.

The edit_macros.pt in Archetypes starts with a html tag having a i18n:domain, then a macro with the input element included. Simplified this looks like this:

<html i18n:domain="plone">
<div metal:define-macro="body">

<input class="context" type="submit"
   value="Save"
   i18n:attributes="value label_save;" />

</div>
</html>

The corresponding Chameleon code is again simplified:

def initialize(nothing, tales, modules):
   __marker_default = _Placeholder()

   def render_body(__stream, econtext, rcontext):
       __i18n_domain = None

       # <Translate msgid=u'label_save' node=<_ast.Str object at 0x10a77e350> at 10a77e390> -> __attr_value
       __attr_value = u'Save'
       __attr_value = translate(u'label_save', default=__attr_value, domain=__i18n_domain)

   def render_footer(__stream, econtext, rcontext):
       __i18n_domain = None

   def render(__stream, econtext, rcontext):
       __i18n_domain = None

       __previous_i18n_domain_4470599376 = __i18n_domain
       __i18n_domain = u'plone'

       # call all macros

       __i18n_domain = __previous_i18n_domain_4470599376

All the macros set the __i18n_domain to None and don't inherit the setting from the outer template. So when the macro is called, the domain is None and no translation can be found.

I think the i18n:domain setting needs to be inherited by the macros unless explicitly overridden.

plone's call to test() doesn't work

in many of plone's page templates, a test function is called like so:

<div tal:attributes="class python:test(context.Format() in ('text/structured',
                           'text/x-rst', ), 'stx' + kss_class, 'plain' + kss_class)">
[...]

as it is the case with:

Products.CMFPlone-4.1-py2.6.egg/Products/CMFPlone/skins/plone_content/newsitem_view.pt

which sometimes lead into an error (but not always, as it seems...).

this leads into a traceback like this:

2011-07-22 14:05:04 ERROR Zope.SiteErrorLog 1311336304.710.949506134619 http://helsinki.at/10.-attac-sommerakademie/newsitem_view
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 240, in _exec
  Module Products.CMFCore.FSPageTemplate, line 180, in pt_render
  Module Products.PageTemplates.PageTemplate, line 79, in pt_render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module five.pt.patches, line 127, in __call__
  Module z3c.pt.pagetemplate, line 118, in render
  Module chameleon.zpt.template, line 107, in render
  Module chameleon.template, line 167, in render
  Module newsitem_view_1c7f09bcd33e6a8ac8df2d95ad32a699c390e228, line 665, in render
  Module main_template_2c68c184a30c494e723cb8e596b59dd1f3dbee88, line 2392, in render_master
  Module main_template_2c68c184a30c494e723cb8e596b59dd1f3dbee88, line 924, in render_content
  Module newsitem_view_1c7f09bcd33e6a8ac8df2d95ad32a699c390e228, line 646, in __fill_content_core
  Module newsitem_view_1c7f09bcd33e6a8ac8df2d95ad32a699c390e228, line 393, in render_content_core
  Module newsitem_view_1c7f09bcd33e6a8ac8df2d95ad32a699c390e228, line 489, in render_text_field_view
  Module chameleon.utils, line 228, in __getitem__
NameError: test

followed by:

2011-07-22 14:05:18 ERROR root Exception while rendering an error message
Traceback (most recent call last):
  File "/www/plone/buildout-common/eggs-plone4/Zope2-2.13.8-py2.6.egg/OFS/SimpleItem.py", line 241, in raise_standardErrorMessage
    v = s(**kwargs)
  File "/www/plone/buildout-common/eggs-plone4/Products.CMFCore-2.2.4-py2.6.egg/Products/CMFCore/FSPythonScript.py", line 130, in __call__
    return Script.__call__(self, *args, **kw)
  File "/www/plone/buildout-common/eggs-plone4/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 322, in __call__
    return self._bindAndExec(args, kw, None)
  File "/www/plone/buildout-common/eggs-plone4/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 359, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "/www/plone/buildout-common/eggs-plone4/Products.PythonScripts-2.13.0-py2.6.egg/Products/PythonScripts/PythonScript.py", line 344, in _exec
    result = f(*args, **kw)
  File "Script (Python)", line 34, in standard_error_message
  File "/www/plone/buildout-common/eggs-plone4/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 322, in __call__
    return self._bindAndExec(args, kw, None)
  File "/www/plone/buildout-common/eggs-plone4/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 359, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "/www/plone/buildout-common/eggs-plone4/Products.CMFCore-2.2.4-py2.6.egg/Products/CMFCore/FSPageTemplate.py", line 240, in _exec
    result = self.pt_render(extra_context=bound_names)
  File "/www/plone/buildout-common/eggs-plone4/Products.CMFCore-2.2.4-py2.6.egg/Products/CMFCore/FSPageTemplate.py", line 180, in pt_render
    self, source, extra_context
  File "/www/plone/buildout-common/eggs-plone4/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/PageTemplate.py", line 79, in pt_render
    showtal=showtal)
  File "/www/plone/buildout-common/eggs-plone4/zope.pagetemplate-3.5.2-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File "/www/plone/buildout-common/eggs-plone4/five.pt-2.1.2-py2.6.egg/five/pt/patches.py", line 127, in __call__
    result = self.template.render(**context)
  File "/www/plone/buildout-common/eggs-plone4/z3c.pt-2.0-py2.6.egg/z3c/pt/pagetemplate.py", line 118, in render
    return base_renderer(**context)
  File "/www/plone/buildout-common/eggs-plone4/Chameleon-2.0-py2.6.egg/chameleon/zpt/template.py", line 107, in render
    return super(PageTemplate, self).render(**k)
  File "/www/plone/buildout-common/eggs-plone4/Chameleon-2.0-py2.6.egg/chameleon/template.py", line 167, in render
    self._render(stream, econtext, rcontext)
  File "/www/plone/thet.helsinki.buildout/var/chameleon-cache/default_error_message_04e5bb8175b2d648819c536f541e12863fe4a931.py", line 3101, in render
    __macro.include(__stream, econtext.copy(), rcontext)
  File "/www/plone/thet.helsinki.buildout/var/chameleon-cache/main_template_2c68c184a30c494e723cb8e596b59dd1f3dbee88.py", line 2392, in render_master
    render_content(__stream, econtext.copy(), rcontext)
  File "/www/plone/thet.helsinki.buildout/var/chameleon-cache/main_template_2c68c184a30c494e723cb8e596b59dd1f3dbee88.py", line 1007, in render_content
    __slot_main(__stream, econtext.copy(), econtext)
  File "/www/plone/thet.helsinki.buildout/var/chameleon-cache/default_error_message_04e5bb8175b2d648819c536f541e12863fe4a931.py", line 772, in __fill_main
    __value = getitem('test')((getitem('result_type') in getitem('use_view_action')), (getitem('result_url') + '/view'), getitem('result_url'))
  File "/www/plone/buildout-common/eggs-plone4/Chameleon-2.0-py2.6.egg/chameleon/utils.py", line 228, in __getitem__
    raise NameError(key)
NameError: test

where the referenced "newsitem_view_1c7f09bcd33e6a8ac8df2d95ad32a699c390e228, line 489, in render_text_field_view" reads so:

487         # <Expression u"python:test(context.Format() in ('text/structured',\n                                                   'text/x-rst', ), 'stx' + kss_class, 'plain' + kss_class)" (46:35)> -> __attr_class
488         try:
489             __attr_class = getitem('test')((_guarded_getattr(getitem('context'), 'Format')() in ('text/structured', 'text/x-rst', )), ('stx' + getitem('kss_class')), ('plain' + getitem('kss_class')))
490         except:
491             rcontext.setdefault('__error__', []).append((u"python:test(context.Format() in ('text/structured',\n                                                   'text/x-rst', ), 'stx' + kss_class, 'plain' + kss_class)", 46, 35, '/www    /plone/buildout-common/eggs-plone4/Products.CMFPlone-4.1-py2.6.egg/Products/CMFPlone/skins/plone_content/newsitem_view.pt', _sys.exc_info()[1], ))
492             raise

"ExpressionError: invalid syntax" on "&lt;"

I had to make this change to workaround a chameleon error. Here's the TB::

Failed example:
    portal.restrictedTraverse('update_stock_portlet')(
        assignment='plone.rightcolumn/bar-header')
Exception raised:
    Traceback (most recent call last):
      File "/home/xen/src/python/parts/opt/lib/python2.7/doctest.py", line 1254, in __run
        compileflags, 1) in test.globs
      File "<doctest README.txt[16]>", line 2, in <module>
        assignment='plone.rightcolumn/bar-header')
      File "/home/xen/src/work/ovt.buildout/src/collective.periodicportlet/collective/periodicportlet/stock.py", line 67, in __call__
        assign.text = self.index(**quote)
      File "/usr/local/lib/python/site-packages/Zope2-2.13.8-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 125, in __call__
        return self.im_func(im_self, *args, **kw)
      File "/usr/local/lib/python/site-packages/Zope2-2.13.8-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
        sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
      File "/usr/local/lib/python/site-packages/zope.pagetemplate-3.5.2-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 107, in pt_render
        raise PTRuntimeError(str(self._v_errors))
       - Warning: Compilation failed
       - Warning: chameleon.exc.ExpressionError: invalid syntax
       - String:   "options['delta']>0 and 'stockQuoteUp' or options['delta']&lt;0 and 'stockQuoteDown'"
       - Filename: /home/xen/src/work/ovt.buildout/src/collective.periodicportlet/collective/periodicportlet/stock.pt
       - Location: (19:37)
    PTRuntimeError: ['Compilation failed', u'chameleon.exc.ExpressionError: invalid syntax\n\n   - String:   "options[\'delta\']>0 and \'stockQuoteUp\' or options[\'delta\']&lt;0 and \'stockQuoteDown\'"\n   - Filename: /home/xen/src/work/ovt.buildout/src/collective.periodicportlet/collective/periodicportlet/stock.pt\n   - Location: (19:37)']

Here's the TB if I use "<" and ">"::

Failed example:
    portal.restrictedTraverse('update_stock_portlet')(
        assignment='plone.rightcolumn/bar-header')
Exception raised:
    Traceback (most recent call last):
      File "/home/xen/src/python/parts/opt/lib/python2.7/doctest.py", line 1254, in __run
        compileflags, 1) in test.globs
      File "<doctest README.txt[16]>", line 2, in <module>
        assignment='plone.rightcolumn/bar-header')
      File "/home/xen/src/work/ovt.buildout/src/collective.periodicportlet/collective/periodicportlet/stock.py", line 67, in __call__
        assign.text = self.index(**quote)
      File "/usr/local/lib/python/site-packages/Zope2-2.13.8-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 125, in __call__
        return self.im_func(im_self, *args, **kw)
      File "/usr/local/lib/python/site-packages/Zope2-2.13.8-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
        sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
      File "/usr/local/lib/python/site-packages/zope.pagetemplate-3.5.2-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 107, in pt_render
        raise PTRuntimeError(str(self._v_errors))
       - Warning: Compilation failed
       - Warning: chameleon.exc.ParseError: Unexpected end tag.

       - String:   "</span>"
       - Filename: /home/xen/src/work/ovt.buildout/src/collective.periodicportlet/collective/periodicportlet/stock.pt
       - Location: (28:2)
    PTRuntimeError: ['Compilation failed', u'chameleon.exc.ParseError: Unexpected end tag.\n\n   - String:   "</span>"\n   - Filename: /home/xen/src/work/ovt.buildout/src/collective.periodicportlet/collective/periodicportlet/stock.pt\n   - Location: (28:2)']

I've tried various combinations of ">", "<", ">", "<", "lt" and "gt", all of which work without Chameleon but only "lt" and "gt_" work under chameleon. I'm using that workaround for now so I'm fine if you just want to close this ticket, but it is an incompatibility and I thought at least I should document it.

tal:on-error is not processed correctly

A template like:

<tal:block tal:on-error="structure python: '&lt;i&gt;error!&lt;/i&gt;'">
  <i tal:content="python: 1/0">
</tal:block>

Will cause:

Traceback (most recent call last):
  [...]
  File "Zope2-2.12.19-py2.6-linux-x86_64.egg/Shared/DC/Scripts/Bindings.py", line 324, in __call__
    return self._bindAndExec(args, kw, None)
  File "Zope2-2.12.19-py2.6-linux-x86_64.egg/Shared/DC/Scripts/Bindings.py", line 361, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "Zope2-2.12.19-py2.6-linux-x86_64.egg/Products/PageTemplates/ZopePageTemplate.py", line 335, in _exec
    result = self.pt_render(extra_context=bound_names)
  File "Zope2-2.12.19-py2.6-linux-x86_64.egg/Products/PageTemplates/ZopePageTemplate.py", line 432, in pt_render
    result = PageTemplate.pt_render(self, source, extra_context)
  File "Zope2-2.12.19-py2.6-linux-x86_64.egg/Products/PageTemplates/PageTemplate.py", line 80, in pt_render
    showtal=showtal)
  File "zope.pagetemplate-3.5.2-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 107, in pt_render
    raise PTRuntimeError(str(self._v_errors))
   - Warning: Compilation failed
   - Warning: chameleon.exc.ExpressionError: Not a valid path-expression.

 - String:   "structure python: '<i>error!</i>'"
 - Filename: foo
 - Location: (1:25)
PTRuntimeError: ['Compilation failed', u'chameleon.exc.ExpressionError: Not a valid path-expression.\n\n - String:   "structure python: \'<i>error!</i>\'"\n - Filename: foo\n - Location: (1:25)']

And, even if we remove structure from the on-error attribute, then the actual exception is not caught, and the on-error definition is not executed.

I've just committed a test to five.pt demonstrating this behaviour.

chameleon generates syntactically incorrect code

page template was modified on windows, it contains \r symbols. chameleon insert this symbol as comment
and it brake syntax.

            <input^M
                  id="filename_normalization"^M
                  name="filename_normalization"^M
                  value="relaxed_normalization"^M
                  type="radio"^M
                  tal:attributes="checked relaxed_normalization" />^M
                  <label for="relaxed_normalization">Change only non-ascii characters in file names</label><br />^M

generated code:

            # <input^M ... (52:12)
            # --------------------------------------------------------
            __append(u'<input\r')
            __append(u'\n                  id="filename_normalization"')
            __append(u'\r\n                  name="filename_normalization"')
            __append(u'\r\n                  value="relaxed_normalization"')
            __append(u'\r\n                  type="radio"')

Module Products.CMFCore.FSPageTemplate, line 180, in pt_render
Module Products.PageTemplates.PageTemplate, line 79, in pt_render
Module zope.pagetemplate.pagetemplate, line 107, in pt_render
Warning: Compilation failed
Warning: exceptions.IndentationError: unindent does not match any outer indentation level (prefs_plone_desktop_487edd55155ca007804ae04c83faec2ba4174991.py, line 430)

incompatibility with metal:fill-slot

Hi,
The code below was working in chameleon v1.2, but in current not.

<div id="profil_lewa" metal:fill-slot="left" metal:use-macro="templates['profile_left']"></div>

The workaround is:

<div id="profil_lewa" metal:fill-slot="left">
     <div metal:use-macro="templates['profile_left']" tal:omit-tag="" />
 </div>

Is this behaviour desired?

TypeError: 'functools.partial' object is unsubscriptable

Plone4.1, chameleon 2.2, five.pt 2.1.4

http://localhost:8080/Plone/recently_modified

  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 240, in _exec
  Module Products.CMFCore.FSPageTemplate, line 180, in pt_render
  Module Products.PageTemplates.PageTemplate, line 79, in pt_render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module five.pt.patches, line 127, in __call__
  Module z3c.pt.pagetemplate, line 125, in render
  Module chameleon.zpt.template, line 117, in render
  Module chameleon.template, line 195, in render
  Module chameleon.template, line 177, in render
  Module 744966656bb28c831d1d99184e0ba70cca72ec5a.py, line 1216, in render
  Module e4fad6f449444ac299447da55d1dfcae62916c1c.py, line 2481, in render_master
  Module e4fad6f449444ac299447da55d1dfcae62916c1c.py, line 1035, in render_content
  Module 744966656bb28c831d1d99184e0ba70cca72ec5a.py, line 88, in __fill_main
  Module Products.CMFPlone.CatalogTool, line 430, in searchResults
  Module Products.ZCatalog.ZCatalog, line 604, in searchResults
  Module Products.ZCatalog.Catalog, line 902, in searchResults
  Module Products.ZCatalog.Catalog, line 528, in search
  Module Products.ExtendedPathIndex.ExtendedPathIndex, line 341, in _apply_index
  Module Products.ExtendedPathIndex.ExtendedPathIndex, line 198, in search
TypeError: 'functools.partial' object is unsubscriptable

 - Expression: "python:container.portal_catalog(sort_on='modified',sort_order='reverse',path=path)"
 - Filename:   <string>
 - Location:   (16:24)
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper recently_modified at 0xc359d4c>
               modules: <instance - at 0xa808eac>
               here: <ImplicitAcquisitionWrapper Plone at 0xbff2d24>
               user: <ImplicitAcquisitionWrapper - at 0xc35e374>
               nothing: <NoneType - at 0x823c0b8>
               traverse_subpath: <list - at 0xc77922c>
               convert: <function translate at 0xcec8d4c>
               container: <ImplicitAcquisitionWrapper Plone at 0xbff2d24>
               default: <object - at 0xb7392688L>
               request: <instance - at 0xc74548c>
               wrapped_repeat: <SafeMapping - at 0xc06920c>
               decode: <function decode at 0xcec8a3c>
               context: <ImplicitAcquisitionWrapper Plone at 0xbff2d24>
               translate: <function translate at 0xcec8d4c>
               root: <ImplicitAcquisitionWrapper Zope at 0xbff298c>
               options: {...} (1)
               loop: {...} (1)

portal_javascripts and portal_css don't work with five.pt-2.1.2

Hi,

I'm working on a project based on Plone 4.1 and today I've updated five.pt from 2.1.1 to 2.1.2. Then I've noticed that when visiting portal_javascripts and portal_css in ZMI I get an error. I've downgraded back to 2.1.1 and the errors are gone.

Here are the stack traces:


portal_javascripts:


2011-07-22 10:06:37 ERROR Zope.SiteErrorLog 1311321997.580.221115496708 http://localhost:8480/SF4/portal_javascripts/manage_jsForm
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in call
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PageTemplates.PageTemplateFile, line 130, in _exec
Module Products.PageTemplates.PageTemplate, line 79, in pt_render
Module zope.pagetemplate.pagetemplate, line 113, in pt_render
Module five.pt.patches, line 127, in call
Module z3c.pt.pagetemplate, line 118, in render
Module chameleon.zpt.template, line 107, in render
Module chameleon.template, line 183, in render
Module chameleon.template, line 167, in render
Module jsconfig_cf3c9a4d72231c9ca2eef627e9162821a2002802, line 728, in render
Module chameleon.utils, line 228, in getitem
RenderError: An uncaught exception was raised.

NameError: test

  • Expression: "python:test(resourceExists, nothing, 'notFound')"
  • Filename: /mnt/home/zope/bundles/eggs/Products.ResourceRegistries-2.0.4-py2.7.egg/Products/ResourceRegistries/www/jsconfig.zpt
  • Location: (191:38)
  • Arguments: repeat: {...} (0)
    template: <ImplicitAcquisitionWrapper manage_jsForm at 0x84f5dc0>
    exists: <instancemethod evaluate_exists at 0x7bfafa0>
    modules: <instance - at 0x13ca950>
    here: <ImplicitAcquisitionWrapper portal_javascripts at 0x84f5b90>
    portal: <ImplicitAcquisitionWrapper SF4 at 0x8518410>
    user: <ImplicitAcquisitionWrapper - at 0x84f5280>
    nothing: <NoneType - at 0x747da0>
    path: <instancemethod evaluate_path at 0x84ef280>
    convert: <function translate at 0x8b41b18>
    container: <ImplicitAcquisitionWrapper portal_javascripts at 0x84f5b90>
    script: <JavaScript - at 0x8e991b8>
    default: <NoneType - at 0x747da0>
    root: <ImplicitAcquisitionWrapper Zope at 0x6cee230>
    _expr_result: 1
    error: <list - at 0x87d2170>
    request: <instance - at 0x9cad830>
    wrapped_repeat: <SafeMapping - at 0x75a04c8>
    decode: <function decode at 0x8b41a28>
    macros: <Macros - at 0x8c10130>
    resourceExists: 1
    context: <ImplicitAcquisitionWrapper portal_javascripts at 0x84f5b90>
    translate: <function translate at 0x8b41b18>
    _ignore: <ImplicitAcquisitionWrapper jquery.js at 0x8511190>
    options: {...} (1)
    loop: {...} (1)
    attrs: {...} (1)

portal_css


2011-07-22 10:01:17 ERROR Zope.SiteErrorLog 1311321677.010.584690142059 http://localhost:8480/SF4/portal_css/manage_cssForm
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in call
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PageTemplates.PageTemplateFile, line 130, in _exec
Module Products.PageTemplates.PageTemplate, line 79, in pt_render
Module zope.pagetemplate.pagetemplate, line 113, in pt_render
Module five.pt.patches, line 127, in call
Module z3c.pt.pagetemplate, line 118, in render
Module chameleon.zpt.template, line 107, in render
Module chameleon.template, line 183, in render
Module chameleon.template, line 167, in render
Module cssconfig_eca0d4d3868828aa578ff49d4d6d6f772aabc99b, line 817, in render
Module chameleon.utils, line 228, in getitem
RenderError: An uncaught exception was raised.

NameError: test

  • Expression: "python:test(resourceExists, nothing, 'notFound')"
  • Filename: /mnt/home/zope/bundles/eggs/Products.ResourceRegistries-2.0.4-py2.7.egg/Products/ResourceRegistries/www/cssconfig.zpt
  • Location: (205:38)
  • Arguments: repeat: {...} (0)
    template: <ImplicitAcquisitionWrapper manage_cssForm at 0x7028e60>
    exists: <instancemethod evaluate_exists at 0x6d4e7d0>
    modules: <instance - at 0xd6e950>
    stylesheet: <Stylesheet - at 0x8849140>
    here: <ImplicitAcquisitionWrapper portal_css at 0x7028dc0>
    portal: <ImplicitAcquisitionWrapper SF4 at 0x6fb0280>
    user: <ImplicitAcquisitionWrapper - at 0x7028eb0>
    nothing: <NoneType - at 0x747da0>
    path: <instancemethod evaluate_path at 0x6fd2870>
    convert: <function translate at 0x82fad70>
    container: <ImplicitAcquisitionWrapper portal_css at 0x7028dc0>
    default: <NoneType - at 0x747da0>
    root: <ImplicitAcquisitionWrapper Zope at 0x6f0d0a0>
    _expr_result: 1
    error: <list - at 0x6bcf050>
    request: <instance - at 0x7f56e18>
    wrapped_repeat: <SafeMapping - at 0x5e44e68>
    decode: <function decode at 0x82fade8>
    macros: <Macros - at 0x82dc3d0>
    resourceExists: 1
    context: <ImplicitAcquisitionWrapper portal_css at 0x7028dc0>
    translate: <function translate at 0x82fad70>
    _ignore: <ImplicitAcquisitionWrapper member.css at 0x712f7d0>
    options: {...} (1)
    loop: {...} (1)
    attrs: {...} (1)

I'm not sure if this is an issue with five.pt or with Products.ResourceRegistries and I'm sorry if I chose the wrong product.

Bes regards,
Maciek

SyntaxError in tales python expression

I've got errors while applying operators in python expression.

 from chameleon import PageTemplate
 PageTemplate('<a tal:content="addr+'town'"></a>')(addr='home') # SyntaxError
 PageTemplate('<a tal:attributes="href addr+'?page=1;#results'"></a>')(addr='home')  # SyntaxError

In chameleon v1.2 this was working

Plone 4.1: UnboundLocalError: local variable '__default_123305040' referenced before assignment

Rendering the Plone 4.1 front-page with five.pt gives me

Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Products.Five.browser.metaconfigure, line 476, in call
Module Products.Five.browser.pagetemplatefile, line 125, in call
Module Products.Five.browser.pagetemplatefile, line 59, in call
Module zope.pagetemplate.pagetemplate, line 113, in pt_render
Module five.pt.patches, line 129, in call
Module z3c.pt.pagetemplate, line 147, in render
Module chameleon.zpt.template, line 211, in render
Module chameleon.template, line 188, in render
Module 081ad3d18c9d2ce657ad16033180487f5c493273.py, line 732, in render
UnboundLocalError: local variable '__default_123305040' referenced before assignment

Eggs:

sys.path[0:0] = [
'/home/ajung/.buildout/eggs/Zope2-2.13.8-py2.6.egg',
'/home/ajung/.buildout/eggs/Plone-4.1-py2.6.egg',
'/home/ajung/.buildout/eggs/PILwoTk-1.1.6.4-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/BeautifulSoup-3.2.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ImageEditor-1.8-py2.6.egg',
'/work/develop/sandboxes/zopyx.authoring/src/Products.DataGridField',
'/home/ajung/.buildout/eggs/archetypes.schemaextender-2.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/collective.quickupload-1.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/sauna.reload-0.3.2-py2.6.egg',
'/home/ajung/.buildout/eggs/collective.plonefinder-1.0.2-py2.6.egg',
'/work/develop/sandboxes/zopyx.authoring/src/zopyx.authoring',
'/work/develop/sandboxes/zopyx.authoring/src/zopyx.smartprintng.plone',
'/work/develop/sandboxes/zopyx.authoring/src/zopyx.smartprintng.cart',
'/home/ajung/.buildout/eggs/zopyx.tinymceplugins.imgmap-0.3.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.discussion-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/five.pt-2.1.5-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.recipe.zope2instance-4.1.7-py2.6.egg',
'/home/ajung/.buildout/eggs/zc.recipe.egg-1.2.2-py2.6.egg',
'/home/ajung/.buildout/eggs/mailinglogger-3.3.3-py2.6.egg',
'/home/ajung/.buildout/eggs/distribute-0.6.19-py2.6.egg',
'/home/ajung/.buildout/eggs/zc.buildout-1.4.4-py2.6.egg',
'/home/ajung/.buildout/eggs/sourcecodegen-0.6.14-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.pt-2.1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.uuid-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.form-2.4.3-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.site-3.9.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.lifecycleevent-3.6.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.container-3.11.2-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/zope.event-3.5.0_1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.annotation-3.5.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.component-3.9.5-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.interface-3.6.3-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/ZODB3-3.10.3-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/plone.z3cform-0.7.7-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.registry-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.indexer-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.z3cform-0.5.6-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.registry-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.layout-2.1.8-py2.6.egg',
'/home/ajung/.buildout/eggs/collective.monkeypatcher-1.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/collective.autopermission-1.0b2-py2.6.egg',
'/home/ajung/.buildout/eggs/lxml-2.2.8-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/zopyx.smartprintng.client-0.8.2-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.jbot-0.6.3-py2.6.egg',
'/home/ajung/.buildout/eggs/cssutils-0.9.8a3-py2.6.egg',
'/home/ajung/.buildout/eggs/ordereddict-1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/simpledropbox-0.2.2-py2.6.egg',
'/home/ajung/.buildout/eggs/watchdog-0.5.4-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.autoinclude-0.3.4-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.uuid-1.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/collective.js.jqueryui-1.8.13.1-py2.6.egg',
'/home/ajung/.buildout/eggs/wicked-1.1.9-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.openid-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.iterate-2.1.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.caching-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.kupu-1.5.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFPlone-4.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFPlacefulWorkflow-1.5.4-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.StandardCacheManagers-2.13.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PythonScripts-2.13.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.MIMETools-2.13.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.MailHost-2.13.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ExternalMethod-2.13.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.BTreeFolder2-2.13.3-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.viewlet-3.7.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.traversing-3.13.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.testing-3.9.6-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.testbrowser-3.11.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.tales-3.5.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.tal-3.5.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.structuredtext-3.5.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.size-3.4.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.sequencesort-3.4.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.sendmail-3.7.4-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.security-3.7.4-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/zope.schema-3.6.4-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.publisher-3.12.6-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.ptresource-3.9.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.proxy-3.6.1-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/zope.processlifetime-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.pagetemplate-3.5.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.location-3.9.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.i18nmessageid-3.5.3-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/zope.i18n-3.7.4-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.exceptions-3.6.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.deferredimport-3.5.3-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.contenttype-3.5.3-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.contentprovider-3.7.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.configuration-3.7.4-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.browserresource-3.10.3-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.browserpage-3.12.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.browsermenu-3.9.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.browser-1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/zLOG-2.11.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zExceptions-2.13.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zdaemon-2.0.4-py2.6.egg',
'/home/ajung/.buildout/eggs/transaction-1.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/tempstorage-2.12.1-py2.6.egg',
'/home/ajung/.buildout/eggs/pytz-2011g-py2.6.egg',
'/home/ajung/.buildout/eggs/initgroups-2.13.0-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/docutils-0.7-py2.6.egg',
'/home/ajung/.buildout/eggs/ZopeUndo-2.12.0-py2.6.egg',
'/home/ajung/.buildout/eggs/ZConfig-2.9.0-py2.6.egg',
'/home/ajung/.buildout/eggs/RestrictedPython-3.6.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Record-2.13.0-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/Products.ZCTextIndex-2.13.2-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/Products.ZCatalog-2.13.15-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.OFSP-2.13.2-py2.6.egg',
'/home/ajung/.buildout/eggs/Persistence-2.13.2-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/MultiMapping-2.13.0-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/Missing-2.13.1-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/ExtensionClass-2.13.2-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/DocumentTemplate-2.13.1-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/DateTime-2.12.6-py2.6.egg',
'/home/ajung/.buildout/eggs/Acquisition-2.13.8-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/AccessControl-2.13.4-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/Chameleon-2.4.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.broken-3.6.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.filerepresentation-3.6.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.dottedname-3.4.6-py2.6.egg',
'/home/ajung/.buildout/eggs/zc.lockfile-1.0.0-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.batching-1.1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFCore-2.2.4-py2.6.egg',
'/home/ajung/.buildout/eggs/collective.z3cform.datetimewidget-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.formwidget.query-0.5-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.kss-1.6.2-py2.6.egg',
'/home/ajung/.buildout/eggs/kss.core-1.6.1-py2.6.egg',
'/home/ajung/.buildout/eggs/elementtree-1.2.7_20070827_preview-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.statusmessages-4.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.GenericSetup-1.6.3-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.autoform-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.supermodel-1.0.3-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFEditions-2.1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFDynamicViewFTI-4.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFDefault-2.2.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.deprecation-3.4.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.portlets-2.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.memoize-1.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.locking-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.i18n-2.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.viewletmanager-2.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.portlets-2.1.5-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.controlpanel-2.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/poster-0.8.1-py2.6.egg',
'/home/ajung/.buildout/eggs/argparse-1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Brownie-0.5.1-py2.6.egg',
'/home/ajung/.buildout/eggs/pathtools-0.1.2-py2.6.egg',
'/home/ajung/.buildout/eggs/argh-0.14.1-py2.6.egg',
'/home/ajung/.buildout/eggs/PyYAML-3.10-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/zope.app.publisher-3.10.2-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PluggableAuthService-1.7.5-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PlonePAS-4.0.8-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.openid-2.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.DCWorkflow-2.2.3-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.Archetypes-1.7.6-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.zcmlhook-1.0b1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.protect-2.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.cachepurging-1.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.caching-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/python_dateutil-1.5-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PortalTransforms-2.0.7-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.MimetypesRegistry-2.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.outputfilters-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.locales-3.6.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plonetheme.sunburst-1.1.5-py2.6.egg',
'/home/ajung/.buildout/eggs/plonetheme.classic-1.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.portlet.static-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.portlet.collection-2.0.3-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.theme-2.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.session-3.5-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.intelligenttext-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.fieldsets-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.contentrules-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.browserlayer-2.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.workflow-2.0.4-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.vocabularies-2.1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.upgrade-1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.users-1.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.redirector-1.1.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.locales-4.0.8-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.linkintegrity-1.4.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.jquerytools-1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.i18n-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.form-2.0.3-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.folder-1.0.4-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.customerize-1.2.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.contentrules-2.1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.content-2.0.7-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.contentmenu-2.0.4-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.blob-1.5-py2.6.egg',
'/home/ajung/.buildout/eggs/five.customerize-1.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/five.localsitemanager-2.0.5-py2.6.egg',
'/home/ajung/.buildout/eggs/borg.localrole-3.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/archetypes.referencebrowserwidget-2.2-py2.6.egg',
'/home/ajung/.buildout/eggs/archetypes.kss-1.7.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.TinyMCE-1.2.4-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ResourceRegistries-2.0.4-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PluginRegistry-1.3b1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PloneLanguageTool-3.2.3-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PlacelessTranslationService-2.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PasswordResetTool-2.0.6-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ExternalEditor-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ExtendedPathIndex-2.9-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFUid-2.2.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFQuickInstallerTool-3.0.5-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFFormController-3.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFDiffTool-2.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFCalendar-2.2.2-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFActionIcons-2.1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ATContentTypes-2.1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.PloneTestCase-0.9.13-py2.6.egg',
'/home/ajung/.buildout/eggs/mechanize-0.2.5-py2.6.egg',
'/home/ajung/.buildout/eggs/unittest2-0.5.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ZSQLMethods-2.13.3-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.form-4.0.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.publication-3.12.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.pagetemplate-3.11.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.folder-3.5.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.component-3.9.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.datetime-3.4.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.formlib-4.0.5-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ZopeVersionControl-1.1.3-py2.6.egg',
'/home/ajung/.buildout/eggs/five.formlib-1.0.4-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.ramcache-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Unidecode-0.04.1-py2.6.egg',
'/home/ajung/.buildout/eggs/feedparser-5.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.cachedescriptors-3.5.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.componentvocabulary-1.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/python_openid-2.2.5-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.folder-1.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.validation-2.0-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.Marshall-2.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.CMFTestCase-0.9.11-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.keyring-2.0-py2.6.egg',
'/home/ajung/.buildout/eggs/five.globalrequest-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.transformchain-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/z3c.caching-2.0a1-py2.6.egg',
'/home/ajung/.buildout/eggs/Markdown-2.0.3-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.SecureMailHost-1.1.2-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.contentmigration-2.0.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.cache-3.7.0-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.stringinterp-1.0.4-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.scale-1.2.2-py2.6.egg',
'/home/ajung/.buildout/eggs/plone.app.imaging-1.0.5-py2.6.egg',
'/home/ajung/.buildout/eggs/python_gettext-1.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/Products.ATReferenceBrowserWidget-3.0-py2.6.egg',
'/home/ajung/.buildout/eggs/manuel-1.1.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.error-3.7.2-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.authentication-3.7.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.dublincore-3.7.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.content-3.5.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.app.container-3.9.1-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.globalrequest-1.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.hookable-3.4.1-py2.6-linux-x86_64.egg',
'/home/ajung/.buildout/eggs/zope.copypastemove-3.7.0-py2.6.egg',
'/home/ajung/.buildout/eggs/zope.copy-3.5.0-py2.6.egg',
]

Chameleon 2.3.8 fails to install with buildout

Running on OSX 10.6, Python 2.6, Buildout 1.5.2, attempting to install Chameleon 2.3.8 fails whereas the previous 2.3.7 installs correctly.

The following minimal buildout configuration demonstrates the issue

[buildout]
parts =
    Chameleon

[Chameleon]
recipe = zc.recipe.egg
eggs =
    Chameleon==2.3.8

Running it gives the following error output:

Processing Chameleon-2.3.8.tar.gz
Unpacking Chameleon-2.3.8 to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8
Unpacking Chameleon-2.3.8/distribute_setup.py to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/distribute_setup.py
Unpacking Chameleon-2.3.8/Makefile to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/Makefile
Unpacking Chameleon-2.3.8/tox.ini to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/tox.ini
Unpacking Chameleon-2.3.8/LICENSE.txt to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/LICENSE.txt
Unpacking Chameleon-2.3.8/setup.cfg to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/setup.cfg
Unpacking Chameleon-2.3.8/PKG-INFO to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/PKG-INFO
Unpacking Chameleon-2.3.8/docs to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/docs
Unpacking Chameleon-2.3.8/docs/reference.rst to /var/folders/Cf/CfwKcJveEhG+zC8KdLWDv++++TQ/-Tmp-/easy_install-mlelcV/Chameleon-2.3.8/docs/reference.rst
error: None
An error occurred when trying to install Chameleon 2.3.8. Look above this message for any errors that were output by easy_install.
While:
  Installing Chameleon.
  Getting distribution for 'Chameleon==2.3.8'.
Error: Couldn't install: Chameleon 2.3.8

If you change the version bind in the buildout configuration to ==2.3.7 Chameleon installs correctly.

escaped right arrow entity

On Plone 4.1 with five.pt
Chameleon = 2.1
five.pt = 2.1.3
z3c.pt = 2.0
sourcecodegen = 0.6.14

The → for the right arrow entity is escaped, so you see on the page
(4108 → 4109)

You can find this entity in the @@plone-upgrade page for example.

chameleon vs. zpt compatibility

See something like this in customer template which appears to work on zpt but not in chameleon.

        <form tal:attributes="action python:context.absolute_url()+'/'+template.id"
              class="enableAutoFocus"
              method="post"
              id="login_form"
              tal:condition="python:auth">

python:auth throws a NameError in chamelon, it requires a space. not sure you want to fix that or not.
but it did work in zpt, crazy enough.

unicodeerror with &nbsp; on python expressions

The following source, which the reference ZPT implementation doesn't mind, fails to even compile on Chameleon:

<p tal:content="structure python: '&nbsp;'" />

The error is:

PTRuntimeError: ['Compilation failed', "exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\\xa0' in position 1: ordinal not in range(128)"]

Assuming I had to quote all occurrences of & on TAL attributes, I then tried

<p tal:content="structure python: '&amp;nbsp;'" />

But this resulted in the exact same error.

I expected at the very least the second version to work, and the error message on the first version to be meaningful, so I could easily track it down.

As it is, the error message contains no indication on where in the source code I can find the offending text. The in position 1 in the message above refers to the relative position of the offending text inside the python expression, which could be buried in the middle of a large template.

For the record, the following work-around gets the job done:

<p tal:content="structure python: '&amp;''nbsp;'" />

As does:

<p tal:content="structure python: '&amp;' + 'nbsp;'" />

Difficult to debug UnicodeDecodeError

I'm trying out five.pt with Plone 4.1 and getting UnicodeDecodeError errors in my tests. I'd like to try and find what character is causing the issue but the exception thrown is not giving me the line and column. I believe it should

xhtml = etree.HTML(self.site['site-data'].restrictedTraverse('@@standard-page-elements')())

File "c:\sandbox\ourafrica.buildout\eggs\zope2-2.13.8-py2.6.egg\Products\Five\browser\metaconfigure.py", line 476, in call
return self.index(_args, *_kw)
File "c:\sandbox\ourafrica.buildout\eggs\zope2-2.13.8-py2.6.egg\Products\Five\browser\pagetemplatefile.py", line 125, in call
return self.im_func(im_self, _args, *_kw)
File "c:\sandbox\ourafrica.buildout\eggs\zope2-2.13.8-py2.6.egg\Products\Five\browser\pagetemplatefile.py", line 59, in call
sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
File "c:\sandbox\ourafrica.buildout\eggs\zope.pagetemplate-3.5.2-py2.6.egg\zope\pagetemplate\pagetemplate.py", line 107, in pt_render
raise PTRuntimeError(str(self._v_errors))

  • Warning: Compilation failed
  • Warning: exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 539: ordinal not in range(128)
    PTRuntimeError: ['Compilation failed', "exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 539: ordinal not in range(128)
    "]

NameError: portlet_type_name

testing chameleon on a site with Plone 4.1, collective.portlet.tal (trunk) and collective.carousel (1.4) installed I get the following errors:

2011-07-26 20:46:23 ERROR portlets Error while rendering <plone.app.portlets.manager.ColumnPortletManagerRenderer object at 0x8f9be10>
Traceback (most recent call last):
  File "/home/hvelarde/plone-py2.6/eggs/plone.app.portlets-2.1.5-py2.6.egg/plone/app/portlets/manager.py", line 61, in safe_render
    return portlet_renderer.render()
  File "/home/hvelarde/plone-py2.6/cienciasalud/src/collective.portlet.tal/collective/portlet/tal/talportlet.py", line 76, in render
    return pt()
  File "/home/hvelarde/plone-py2.6/eggs/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 322, in __call__
    return self._bindAndExec(args, kw, None)
  File "/home/hvelarde/plone-py2.6/eggs/Zope2-2.13.8-py2.6.egg/Shared/DC/Scripts/Bindings.py", line 359, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "/home/hvelarde/plone-py2.6/eggs/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/ZopePageTemplate.py", line 334, in _exec
    result = self.pt_render(extra_context=bound_names)
  File "/home/hvelarde/plone-py2.6/eggs/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/ZopePageTemplate.py", line 431, in pt_render
    result = PageTemplate.pt_render(self, source, extra_context)
  File "/home/hvelarde/plone-py2.6/eggs/Zope2-2.13.8-py2.6.egg/Products/PageTemplates/PageTemplate.py", line 79, in pt_render
    showtal=showtal)
  File "/home/hvelarde/plone-py2.6/eggs/zope.pagetemplate-3.5.2-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File "/home/hvelarde/plone-py2.6/eggs/five.pt-2.1.3-py2.6.egg/five/pt/patches.py", line 127, in __call__
    result = self.template.render(**context)
  File "/home/hvelarde/plone-py2.6/eggs/z3c.pt-2.0-py2.6.egg/z3c/pt/pagetemplate.py", line 118, in render
    return base_renderer(**context)
  File "/home/hvelarde/plone-py2.6/eggs/Chameleon-2.1-py2.6.egg/chameleon/zpt/template.py", line 111, in render
    return super(PageTemplate, self).render(**k)
  File "/home/hvelarde/plone-py2.6/eggs/Chameleon-2.1-py2.6.egg/chameleon/template.py", line 186, in render
    raise_with_traceback(exc, tb)
  File "/home/hvelarde/plone-py2.6/eggs/Chameleon-2.1-py2.6.egg/chameleon/template.py", line 168, in render
    self._render(stream, econtext, rcontext)
  File "521785c9c0d9f5a4092e44a4382df83b9caadc22.py", line 63, in render
  File "/home/hvelarde/plone-py2.6/eggs/Chameleon-2.1-py2.6.egg/chameleon/utils.py", line 247, in __getitem__
    raise NameError(key)
NameError: portlet_type_name

 - Expression: "portlet_type_name"
 - Filename:   <string>
 - Location:   (1:28)
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper __tal_portlet__ at 0x678a2d0>
               exists: <instancemethod evaluate_exists at 0x6a1f7d0>
               modules: <instance - at 0x23e3518>
               context_state: <ContextState plone_context_state at 0x9af5e50>
               here: <ImplicitAcquisitionWrapper portada at 0x7d86d20>
               nothing: <NoneType - at 0x83d880>
               path: <instancemethod evaluate_path at 0x6b23960>
               attrs: {...} (1)
               traverse_subpath: <list - at 0x79df1b8>
               convert: <function translate at 0x9d6ab90>
               container: <ImplicitAcquisitionWrapper portada at 0x7d86d20>
               default: portlet portlet${portlet_type_name}
               __error__: <list - at 0x7a89b00>
               request: <instance - at 0x8c80e60>
               wrapped_repeat: <SafeMapping - at 0x9a97260>
               decode: <function decode at 0x9d6ac08>
               macros: <Macros - at 0x9d73670>
               context: <ImplicitAcquisitionWrapper portada at 0x7d86d20>
               portal_state: <PortalState plone_portal_state at 0x9af5210>
               translate: <function translate at 0x9d6ab90>
               root: <ImplicitAcquisitionWrapper Zope at 0x8857960>
               options: {...} (1)
               loop: {...} (0)
               user: <ImplicitAcquisitionWrapper - at 0x7d86af0>
> /home/hvelarde/plone-py2.6/eggs/Chameleon-2.1-py2.6.egg/chameleon/utils.py(247)__getitem__()
-> raise NameError(key)
(Pdb) c
2011-07-26 20:48:05 ERROR Zope.SiteErrorLog 1311731285.970.761020040383 http://localhost:8080/Plone/portada/collage_view
Traceback (innermost last):
  Module plone.app.portlets.manager, line 61, in safe_render
  Module collective.portlet.tal.talportlet, line 76, in render
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.PageTemplates.ZopePageTemplate, line 334, in _exec
  Module Products.PageTemplates.ZopePageTemplate, line 431, in pt_render
  Module Products.PageTemplates.PageTemplate, line 79, in pt_render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module five.pt.patches, line 127, in __call__
  Module z3c.pt.pagetemplate, line 118, in render
  Module chameleon.zpt.template, line 111, in render
  Module chameleon.template, line 186, in render
  Module chameleon.template, line 168, in render
  Module 521785c9c0d9f5a4092e44a4382df83b9caadc22.py, line 63, in render
  Module chameleon.utils, line 247, in __getitem__
NameError: portlet_type_name

 - Expression: "portlet_type_name"
 - Filename:   <string>
 - Location:   (1:28)
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper __tal_portlet__ at 0x678a2d0>
               exists: <instancemethod evaluate_exists at 0x6a1f7d0>
               modules: <instance - at 0x23e3518>
               context_state: <ContextState plone_context_state at 0x9af5e50>
               here: <ImplicitAcquisitionWrapper portada at 0x7d86d20>
               nothing: <NoneType - at 0x83d880>
               path: <instancemethod evaluate_path at 0x6b23960>
               attrs: {...} (1)
               traverse_subpath: <list - at 0x79df1b8>
               convert: <function translate at 0x9d6ab90>
               container: <ImplicitAcquisitionWrapper portada at 0x7d86d20>
               default: portlet portlet${portlet_type_name}
               __error__: <list - at 0x7a89b00>
               request: <instance - at 0x8c80e60>
               wrapped_repeat: <SafeMapping - at 0x9a97260>
               decode: <function decode at 0x9d6ac08>
               macros: <Macros - at 0x9d73670>
               context: <ImplicitAcquisitionWrapper portada at 0x7d86d20>
               portal_state: <PortalState plone_portal_state at 0x9af5210>
               translate: <function translate at 0x9d6ab90>
               root: <ImplicitAcquisitionWrapper Zope at 0x8857960>
               options: {...} (1)
               loop: {...} (0)
               user: <ImplicitAcquisitionWrapper - at 0x7d86af0>
> /home/hvelarde/plone-py2.6/eggs/Chameleon-2.1-py2.6.egg/chameleon/utils.py(247)__getitem__()
-> raise NameError(key)
(Pdb) c

chameleon error on triple quoted template-inline python statement

i got an error with chameleon on a triple quoted python statement, which
seems to be syntactically correct:

https://dev.plone.org/collective/browser/collective.disqus/trunk/src/collective/disqus/viewlets/disqus_panel.pt?rev=241524

to bypass the error, i moved the javascript template code into the
viewlet's view, which is an good idea anyways but doesn't solve the
problem at it's root.

thanks for this package!

traceback snippet:

2011-07-18 15:12:14 ERROR Zope.SiteErrorLog 1310994734.410.68857537477
http://localhost:8080/radio-helsinki/helsinki/livestream/@@manage-viewlets
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module plone.app.viewletmanager.manager, line 254, in __call__
  Module Products.Five.browser.pagetemplatefile, line 125, in __call__
  Module Products.Five.browser.pagetemplatefile, line 59, in __call__
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module five.pt.patches, line 134, in __call__
  Module z3c.pt.pagetemplate, line 118, in render
  Module chameleon.zpt.template, line 107, in render
  Module chameleon.template, line 183, in render
  Module chameleon.template, line 167, in render
  Module manage-viewlets_db3bb7fddf155470989f2afe5680df725bf9b6e2, line
484, in render
  Module main_template_2c68c184a30c494e723cb8e596b59dd1f3dbee88, line
2435, in render_master
  Module five.pt.expressions, line 160, in __call__
  Module plone.app.viewletmanager.manager, line 133, in render
  Module plone.app.layout.viewlets.common, line 48, in render
  Module Products.Five.browser.pagetemplatefile, line 125, in __call__
  Module Products.Five.browser.pagetemplatefile, line 59, in __call__
  Module zope.pagetemplate.pagetemplate, line 107, in pt_render
   - Warning: Compilation failed
   - Warning: chameleon.exc.ExpressionError: EOF while scanning
triple-quoted string literal

   - String:   "'''         if (%(enable_sso)s) {           var
disqus_config = function() {             this.page.remote_auth_s3 =
'%(sso_message)s';             this.page.api_key = '%(sso_public_key)s';
if (%(own_login)s) {               this.sso = {                 'name':
'%(sso_site_name)s',                 'button': '%(sso_button_url)s',
'icon': '%(sso_icon_url)s',                 'url': '%(sso_login_url)s',
'logout': '%(sso_logout_url)s',                 'width':
'%(sso_width)s',                 'height':
'%(sso_height)s'              };             }           }         };
var disqus_identifier = '%(disqus_identifier)s';         var disqus_url
= '%(disqus_url)s';         var disqus_developer = %(disqus_developer)s;
(function() {          var dsq = document.createElement('script');
dsq.type = 'text/javascript'; dsq.async = true;          dsq.src =
'http://%(disqus_id)s.disqus.com/embed.js';
(document.getElementsByTagName('head')[0]"
   -
Filename: /home/thet-data/dev/helsinki-web/thet.helsinki.buildout/src/collective.disqus/src/collective/disqus/viewlets/disqus_panel.pt
   - Location: (6:65)
RenderError: An uncaught exception was raised.

PTRuntimeError: ['Compilation failed', u'chameleon.exc.ExpressionError:
EOF while scanning triple-quoted string literal\n\n   - String:
"\'\'\'         if (%(enable_sso)s) {           var disqus_config =
function() {             this.page.remote_auth_s3 = \'%(sso_message)s\';
this.page.api_key = \'%(sso_public_key)s\';             if
(%(own_login)s) {               this.sso = {                 \'name\':
\'%(sso_site_name)s\',                 \'button\': \'%(sso_button_url)s
\',                 \'icon\': \'%(sso_icon_url)s\',
\'url\': \'%(sso_login_url)s\',                 \'logout\':
\'%(sso_logout_url)s\',                 \'width\': \'%(sso_width)s\',
\'height\': \'%(sso_height)s
\'              };             }           }         };         var
disqus_identifier = \'%(disqus_identifier)s\';         var disqus_url =
\'%(disqus_url)s\';         var disqus_developer = %(disqus_developer)s;
(function() {          var dsq = document.createElement(\'script\');
dsq.type = \'text/javascript\'; dsq.async = true;          dsq.src =
\'http://%(disqus_id)s.disqus.com/embed.js\';
(document.getElementsByTagName(\'head\')[0]"\n   -
Filename: /home/thet-data/dev/helsinki-web/thet.helsinki.buildout/src/collective.disqus/src/collective/disqus/viewlets/disqus_panel.pt\n   - Location: (6:65)']

 - Expression: "provider:plone.belowcontent"
 -
Filename:   /home/thet-data/dev/helsinki-web/thet.helsinki.buildout/src/plonetheme.sunburst/plonetheme/sunburst/skins/sunburst_templates/main_template.pt
 - Location:   (138:67)
 - Arguments:  repeat: {...} (0)
               template: <ViewPageTemplateFile - at 0xcb49e8c>
               exists: <instancemethod evaluate_exists at 0xba3a964>
               views: <ViewMapper - at 0xcb4b62c>
               request: <instance - at 0xc3d566c>
               args: <tuple - at 0xb737a02cL>
               here: <ImplicitAcquisitionWrapper livestream at
0xbe4061c>
               user: <ImplicitAcquisitionWrapper - at 0xbe5389c>
               nothing: <NoneType - at 0x823d1b8>
               path: <instancemethod evaluate_path at 0xba3a8c4>
               decode: <function decode at 0xc6df80c>
               convert: <function translate at 0xc6df764>
               container: <ImplicitAcquisitionWrapper livestream at
0xbe4061c>
               default: <object - at 0xb7399698L>
               __slot_main: <list - at 0xcb4b36c>
               __slot_style_slot: <list - at 0xcb4b5cc>
               __error__: <list - at 0xcffbf0c>
               modules: <instance - at 0x95c640c>
               wrapped_repeat: <SafeMapping - at 0xbe53b1c>
               traverse_subpath: <list - at 0xcb47f6c>
               macros: <Macros - at 0xc91998c>
               context: <ImplicitAcquisitionWrapper livestream at
0xbe4061c>
               view: <SimpleViewClass
from /home/thet/.buildout/eggs/plone.app.viewletmanager-2.0.2-py2.6.egg/plone/app/viewletmanager/manage-viewlets.pt manage-viewlets at 0xcb47dac>
               translate: <function translate at 0xc6df764>
               root: <ImplicitAcquisitionWrapper Zope at 0xb3ecaa4>
               options: {...} (0)
               loop: {...} (1)
               __slot_javascript_head_slot: <list - at 0xcb4b40c>
2011-07-18 15:12:14 ERROR root PageTemplateFile: Error in
template /home/thet-data/dev/helsinki-web/thet.helsinki.buildout/src/collective.disqus/src/collective/disqus/viewlets/disqus_panel.pt: Compilation failed
chameleon.exc.ExpressionError: EOF while scanning triple-quoted string
literal

   - String:   "'''         if (%(enable_sso)s) {           var
disqus_config = function() {             this.page.remote_auth_s3 =
'%(sso_message)s';             this.page.api_key = '%(sso_public_key)s';
if (%(own_login)s) {               this.sso = {                 'name':
'%(sso_site_name)s',                 'button': '%(sso_button_url)s',
'icon': '%(sso_icon_url)s',                 'url': '%(sso_login_url)s',
'logout': '%(sso_logout_url)s',                 'width':
'%(sso_width)s',                 'height':
'%(sso_height)s'              };             }           }         };
var disqus_identifier = '%(disqus_identifier)s';         var disqus_url
= '%(disqus_url)s';         var disqus_developer = %(disqus_developer)s;
(function() {          var dsq = document.createElement('script');
dsq.type = 'text/javascript'; dsq.async = true;          dsq.src =
'http://%(disqus_id)s.disqus.com/embed.js';
(document.getElementsByTagName('head')[0]"
   -
Filename: /home/thet-data/dev/helsinki-web/thet.helsinki.buildout/src/collective.disqus/src/collective/disqus/viewlets/disqus_panel.pt
   - Location: (6:65)
^C2011-07-18 15:20:58 INFO SignalHandler Caught signal SIGINT
2

Template viariables errors - names couldn't start with '_'

While I upgrade to chameleon v2 I've got numerous of errors:

NameError: global name '_' is not defined

I've used '_' and '_c' .. for translation strings. The documentation doesn't tell anything about variable names constraints.

The code to pull the error is below:

from chameleon import PageTemplate
PageTemplate('<div tal:content="a()"></div>')(a=lambda:'world')  # this works
PageTemplate('<div tal:content="_()"></div>')(_=lambda:'world')  # this don't

Please make some information about this in documentation (Incompatibilities and differences) or put fixes.

Moreover the link to report bugs on the chameleon main page (http://chameleon.repoze.org/) is out-of-date (it points to launchapd)

Compiler error messages when trying to install Chameleon 2.4.1 on Python 2.5

When trying to install Chameleon 2.4.1 on Python 2.5 I get the following error messages:

(tempenv)notroot@debian:/tmp/tempenv/bin$ easy_install chameleon
Searching for chameleon
Reading http://pypi.python.org/simple/chameleon/
Reading http://www.pagetemplates.org/
Reading http://chameleon.repoze.org
Best match: Chameleon 2.4.1
Downloading http://pypi.python.org/packages/source/C/Chameleon/Chameleon-2.4.1.tar.gz#md5=5c6b5797b6143a7f0dbb1981f5472873
Processing Chameleon-2.4.1.tar.gz
Running Chameleon-2.4.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-V8nNb2/Chameleon-2.4.1/egg-dist-tmp-hZQjtH
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz
Extracting in /tmp/easy_install-V8nNb2/Chameleon-2.4.1/temp/tmpKpdeR8
Now working in /tmp/easy_install-V8nNb2/Chameleon-2.4.1/temp/tmpKpdeR8/distribute-0.6.14
Building a Distribute egg in /tmp/easy_install-V8nNb2/Chameleon-2.4.1
/tmp/easy_install-V8nNb2/Chameleon-2.4.1/distribute-0.6.14-py2.5.egg
build/bdist.linux-x86_64/egg/chameleon/py26.py:4: Warning: 'as' will become a reserved keyword in Python 2.6
File "build/bdist.linux-x86_64/egg/chameleon/py26.py", line 4
except AttributeError as exc:
^
SyntaxError: invalid syntax

/tmp/tempenv/lib/python2.5/site-packages/Chameleon-2.4.1-py2.5.egg/chameleon/py26.py:4: Warning: 'as' will become a reserved keyword in Python 2.6
File "/tmp/tempenv/lib/python2.5/site-packages/Chameleon-2.4.1-py2.5.egg/chameleon/py26.py", line 4
except AttributeError as exc:
^
SyntaxError: invalid syntax

Adding Chameleon 2.4.1 to easy-install.pth file

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 18: ordinal not in range(128)

how to reproduce:

  1. create plone site
  2. edit front-page, change title, use unicode symbols (for example russian: "тест")
  3. open workflow advanced view
    http://localhost:8080/Plone/front-page/content_status_history

chameleon 2.2, five.pt 2.1.4

Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Products.CMFFormController.FSControllerPageTemplate, line 91, in __call__
  Module Products.CMFFormController.BaseControllerPageTemplate, line 31, in _call
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 240, in _exec
  Module Products.CMFCore.FSPageTemplate, line 180, in pt_render
  Module Products.PageTemplates.PageTemplate, line 79, in pt_render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
  Module five.pt.patches, line 127, in __call__
  Module z3c.pt.pagetemplate, line 125, in render
  Module chameleon.zpt.template, line 117, in render
  Module chameleon.template, line 195, in render
  Module chameleon.template, line 177, in render
  Module f2c98a3c6945d1b8be0c2da0e2ecf6ac686c87ed.py, line 6167, in render
  Module eb113b8328d1bb66f3a7371f62f2be7cea36fdcd.py, line 2481, in render_master
  Module eb113b8328d1bb66f3a7371f62f2be7cea36fdcd.py, line 1035, in render_content
  Module f2c98a3c6945d1b8be0c2da0e2ecf6ac686c87ed.py, line 1946, in __fill_main
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 18: ordinal not in range(128)

 - Expression: "string:Select $item_title_or_id"
 - Filename:   <string>
 - Location:   (147:63)
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper content_status_history at 0xaec2b94>
               modules: <instance - at 0x93670ac>
               here: <ImplicitAcquisitionWrapper front-page at 0xaec2234>
               user: <ImplicitAcquisitionWrapper - at 0xaefd0f4>
               nothing: <NoneType - at 0x823c0b8>
               traverse_subpath: <list - at 0xbd2686c>
               convert: <function translate at 0xb6e04fc>
               container: <ImplicitAcquisitionWrapper Plone at 0xad2f9dc>
               default: <object - at 0xb743c688L>
               request: <instance - at 0xb234dac>
               wrapped_repeat: <SafeMapping - at 0xb2f27d4>
               decode: <function decode at 0xb9b5bc4>
               context: <ImplicitAcquisitionWrapper front-page at 0xaec2234>
               translate: <function translate at 0xb6e04fc>
               root: <ImplicitAcquisitionWrapper Zope at 0xad2f70c>
               options: {...} (2)
               loop: {...} (2

Embedded variable parsing failure

The following script emits a parse-time traceback:

template =\
"""
    <script>
      deform.addCallback(
        '${field.oid}',
        function (oid) {
            $('#' + oid).autocomplete({source: ${values}});
            $('#' + oid).autocomplete("option", ${options});
        }
      );
    </script>

"""

from chameleon.zpt.template import PageTemplate

pt = PageTemplate(template)
pt()

The traceback:

Traceback (most recent call last):
  File "fail1.py", line 16, in 
    pt = PageTemplate(template)
  File "/home/chrism/projects/chameleon/src/chameleon/zpt/template.py", line 57, in __init__
    super(PageTemplate, self).__init__(*args, **kwargs)
  File "/home/chrism/projects/chameleon/src/chameleon/template.py", line 115, in __init__
    self.cook(body)
  File "/home/chrism/projects/chameleon/src/chameleon/template.py", line 134, in cook
    program = self._cook(body, digest)
  File "/home/chrism/projects/chameleon/src/chameleon/template.py", line 190, in _cook
    source = self._compile(program)
  File "/home/chrism/projects/chameleon/src/chameleon/template.py", line 206, in _compile
    compiler = Compiler(self.engine, program)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 384, in __init__
    module.body += self.visit(node)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 400, in visit
    iterator = visitor(node)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 444, in visit_MacroProgram
    body += self.visit_Macro(node)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 475, in visit_Macro
    body += itertools.chain(*tuple(map(self.visit, node.body)))
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 401, in visit
    return list(iterator)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 600, in visit_Define
    for stmt in self.visit(node.node):
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 401, in visit
    return list(iterator)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 412, in visit_Element
    for stmt in self.visit(node.content):
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 401, in visit
    return list(iterator)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 405, in visit_Sequence
    for stmt in self.visit(item):
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 400, in visit
    iterator = visitor(node)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 558, in visit_Interpolation
    return expression(store(name), engine) + \
  File "/home/chrism/projects/chameleon/src/chameleon/tales.py", line 422, in __call__
    body += engine(string, target)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 551, in engine
    return self._engine(node, target) + \
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 196, in __call__
    stmts = self.translate(expression, target)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 225, in translate
    stmts = visitor(expression, target)
  File "/home/chrism/projects/chameleon/src/chameleon/compiler.py", line 267, in visit_Expression
    stmts = self.engine(node.value, target)
  File "/home/chrism/projects/chameleon/src/chameleon/tales.py", line 550, in __call__
    return compiler(target, self)
  File "/home/chrism/projects/chameleon/src/chameleon/tales.py", line 147, in __call__
    assignment = self.translate(expression, target)
  File "/home/chrism/projects/chameleon/src/chameleon/tales.py", line 245, in translate
    raise ExpressionError(exc.msg, decoded)
chameleon.exc.ExpressionError: unexpected EOF while parsing

   - String:   "values}"
   - Filename: 
   - Location: (6:49)

Difference in behavior between Chameleon and reference implementation

The ZPT reference implementation allows the following markup structure (which is arguably sketchy)

<div tal:content="string:foobar"><span tal:replace="${context/id}"/></div>

The outer tal:content replaces the contents of the <div> tag with the TALES expression and the invalid TALES expression contained within is ignored. However, when using Chameleon the inner TALES expression is also evaluated which leads to a chameleon.exc.ExpressionError: Not a valid path-expression.

This issue came up while using z3c.form (http://svn.zope.org/z3c.form/trunk/src/z3c/form/browser/orderedselect_input.pt?rev=90975&view=markup) where they have markup such as

      <span id="toDataContainer"
            tal:attributes="id string:${view/id}-toDataContainer">
        <script type="text/javascript" tal:content="string:
          copyDataForSubmit('${view/id}');">
          // initial copying of field "field.to" --> "field"
          copyDataForSubmit("<i tal:replace="${view/id}"/>");
        </script>
      </span>

Arguably this should be changed in z3c.form but should Chameleon behave consistently with the reference implementation in this regard? It does present an obstacle with using Chameleon now with templates from existing packages.

Chameleon2 lost inline Boolean attributes (without tal:attributes)

Something that used to work in Chameleon 1 was:

  <input type="checkbox"
         name="foo"
         checked="${cond and 'checked'}" />

I thought this inline feature was actually quite neat. What I need to do instead in Chameleon 2 is:

  <input type="checkbox"
         name="foo"
         tal:attributes="checked cond and 'checked'" />

Is this a bug?

Unclear support for template names with dots or hyphens

The old zope.pagetemplate implementation supports arbitrary filenames for templates. It looks like Chameleon requires them to be valid Python module names.

I noticed this with a template named "manage-dashboard.pt", overridden via z3c.jbot in a Plone context. While loading that template with the template cache being enabled, I get an error message on the console:

<somedir>/template_cache/plone.app.portlets.browser.templates.manage-dashboard_d7c6cb77a0fc8e04ef7c535b94fb9cd64a795443.py:44:
RuntimeWarning: Parent module 'plone.app.portlets.browser.templates' not found while handling absolute import
import functools

It looks to me like the chameleon.template.BaseTemplateFile._cook method could do some quoting here. In the snippet:

def _cook(self, body, digest):
    filename = os.path.basename(self.filename)
    base, ext = os.path.splitext(filename)
    name = "%s_%s.py" % (base, digest)
    cooked = self.loader.get(name)
    ...

it could quote the base part. I guess both dots and hyphens are problematic. Maybe replacing both of these with underscores would be simple enough.

element attributes getting "" value

The following tal:attributes expression::

tal:attributes="selected python:item['selected'] and 'selected' or ''"

yields the following element attributes under chameleon::

selected=""

when without chameleon it doesn't add the element attribute at all. An example of this is in collective.z3cform.datetimewidget.

It could be argued that the chameleon behavior is right where the reference implementation is wrong, but if the goal is compatibility, then this may need to be fixed.

tal:attributes="disabled python:True and default or 'disabled'"

in plone's user management configlet, columns "Reset password" and
"Remove user" are always disabled.

here is pt:

<input type="checkbox"
   class="noborder notify"
   name="delete:list"
   value=""
   tal:attributes="value userid;
             disabled python:user['can_delete'] and default or 'disabled'" />

this input always has disabled='disabled', it doesn't matter what value
user['can_delete'] has.

but if i use "xxx if xxx else xxx" construct, it works right. like this

 <input type="checkbox"
     class="noborder notify"
     name="delete:list"
     value=""
     tal:attributes="value userid;
                 disabled python:default if user['can_delete'] else 'disabled'" />

can't create event on plone site

I've got this with chameleon 2.3.4, five.pt 2.1.5

How to reproduce:

Got to plone site, select "Event" in add menu, fill form and click save.

Traceback (innermost last):

Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.CMFCore.FSPageTemplate, line 240, in _exec
Module Products.CMFCore.FSPageTemplate, line 180, in pt_render
Module Products.PageTemplates.PageTemplate, line 79, in pt_render
Module zope.pagetemplate.pagetemplate, line 107, in pt_render
Warning: Compilation failed
Warning: exceptions.IndexError: list index out of range
PTRuntimeError: ['Compilation failed', 'exceptions.IndexError: list index out of range']

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.