[Grok-dev] Adding machine example

Luciano Ramalho luciano at ramalho.org
Fri Jun 1 11:48:43 EDT 2007


The app.py code is here:

http://paste.plone.org/14906

The problem I have is *very* basic: I don't know why I can't access
instance variables of the model in the index.pt template.

For example, this line fails:

  <p tal:condition="context/message" tal:replace="context/message" />

The traceback is below.

I know this is too basic, but I reread the tutorial trying to find an
explanation, but could not find it.

Cheers,

Luciano

--
2007-06-01T12:45:55 ERROR SiteError http://localhost:8080/adder/@@index
Traceback (most recent call last):
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/publisher/publish.py",
line 133, in publish
    result = publication.callObject(request, obj)
  File "/Users/luciano/zope3/Adder/eggs/grok-0.9dev_r75634-py2.4.egg/grok/publication.py",
line 41, in callObject
    return super(ZopePublicationSansProxy, self).callObject(request, ob)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/app/publication/zopepublication.py",
line 161, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/publisher/publish.py",
line 108, in mapply
    return debug_call(obj, args)
   - __traceback_info__: <adder.app.Index object at 0x2563570>
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/publisher/publish.py",
line 114, in debug_call
    return obj(*args)
  File "/Users/luciano/zope3/Adder/eggs/grok-0.9dev_r75634-py2.4.egg/grok/components.py",
line 170, in __call__
    return self._render_template()
  File "/Users/luciano/zope3/Adder/eggs/grok-0.9dev_r75634-py2.4.egg/grok/components.py",
line 180, in _render_template
    return self.template.pt_render(namespace)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/pagetemplate/pagetemplate.py",
line 117, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tal/talinterpreter.py",
line 271, in __call__
    self.interpret(self.program)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tal/talinterpreter.py",
line 346, in interpret
    handlers[opcode](self, args)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tal/talinterpreter.py",
line 854, in do_condition
    if not self.tal or self.engine.evaluateBoolean(condition):
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tales/tales.py",
line 701, in evaluateBoolean
    return not not self.evaluate(expr)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tales/tales.py",
line 696, in evaluate
    return expression(self)
   - /Users/luciano/zope3/Adder/src/adder/app_templates/index.pt
   - Line 10, Column 2
   - Expression: <PathExpr standard:u'context/message'>
   - Names:
      {'args': (),
       'context': <adder.app.Adder object at 0x3305130>,
       'default': <object object at 0x40570>,
       'loop': {},
       'nothing': None,
       'options': {},
       'repeat': {},
       'request': <zope.publisher.browser.BrowserRequest instance
URL=http://localhost:8080/adder/@@index>,
       'static': <grok.components.DirectoryResource object at 0x3222210>,
       'template': <index template in
/Users/luciano/zope3/Adder/src/adder/app_templates/index.pt>,
       'usage': <zope.pagetemplate.pagetemplate.TemplateUsage object
at 0x310fa30>,
       'view': <adder.app.Index object at 0x2563570>}
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tales/expressions.py",
line 217, in __call__
    return self._eval(econtext)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tales/expressions.py",
line 194, in _eval
    ob = self._subexprs[-1](econtext)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/tales/expressions.py",
line 124, in _eval
    ob = self._traverser(ob, element, econtext)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/app/pagetemplate/engine.py",
line 68, in __call__
    request=request)
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/traversing/adapters.py",
line 164, in traversePathElement
    return traversable.traverse(nm, further_path)
   - __traceback_info__: (<adder.app.Adder object at 0x3305130>, 'message')
  File "/Users/luciano/zope3/Adder/parts/zope3/lib/python/zope/app/container/traversal.py",
line 100, in traverse
    raise TraversalError(container, name)
TraversalError: (<adder.app.Adder object at 0x3305130>, 'message')
127.0.0.1 - - [1/Jun/2007:12:45:55 -0200] "GET /adder/ HTTP/1.1" 500
83 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3)
Gecko/20070309 Firefox/2.0.0.3"


More information about the Grok-dev mailing list