[Zope3-dev] Job Board Example

Guido van Rossum guido@python.org
Mon, 17 Jun 2002 23:20:07 -0400


> AttributeError
> 
> Traceback (innermost last):
> 
>     * Module Zope.Publisher.Publish, line 39, in publish
>     * Module Zope.App.ZopePublication.ZopePublication, line 117, in callObject
>     * Module Zope.Publisher.mapply, line 106, in mapply
>       __traceback_info__: <security proxied __builtin__.instance method instance at 0x861efec>
>     * Module ZopeProducts.JobBoardI18n.JobCreateView, line 18, in create
>     * Module Zope.PageTemplate.PageTemplate, line 95, in __call__
>     * Module Zope.PageTemplate.PageTemplate, line 113, in pt_render
>       Warning: Macro expansion failed
>       Warning: exceptions.AttributeError: 'Context' object has no attribute 'translate'
>     * Module Zope.TAL.TALInterpreter, line 164, in __call__
>     * Module Zope.TAL.TALInterpreter, line 203, in interpret
>     * Module Zope.TAL.TALInterpreter, line 529, in do_insertTranslation
>     * Module Zope.TAL.TALInterpreter, line 609, in translate
> 
> AttributeError: 'Context' object has no attribute 'translate'

I fixed this.  It was due to perhaps over-cleverness on my part -- or
lack of documentation or something.  The JobBoard example's
JobCreateView class has a page template "thanks" that is not a view
(you can't navigate to it).  So I figured I didn't have to use

    thanks = ViewPageTemplateFile('thanks.pt')

and got away with

    thanks = PageTemplateFile('thanks.pt')

but this uses a more basic version of the TALES engine, imported from
Zope.PageTemplate instead of from Zope.App.PageTemplate.  (I even sent
a question to Jim about this, because slide 34 of his examples is
ambiguous about this issue -- no reply yet).

I can't say I understand how these differ, but I remember I was
sitting next to Jim when he added something to
Zope/App/PageTemplate/Engine.py that did something with proxies, and
that memory somehow helped me realize that there's a Zope-free version
of the PageTemplate code, in the Zope package, and a Zope-aware
version, in the Zope.App package.  (I guess the other clue was the
debug print statement I added that showed that normally there's a
Zope.App.PageTemplate.Engine.ZopeContext object involved, but when it
fails there's a Zope.PageTemplate.TALES.Context object. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)