TypeError:'str' object not callable

I am trying to create a list of talks that I have created . I am getting the following error.

We’re sorry, but there seems to be an error…
Here is the full error message:

Display traceback as text

Traceback (innermost last):

Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Products.Five.browser.metaconfigure, line 485, 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 132, in pt_render
Module five.pt.engine, line 93, in call
Module z3c.pt.pagetemplate, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module 3ef2a5db72e95e7bd0b6d689ac8a4c8b.py, line 152, in render
Module ploneconf.site.browser.views, line 28, in talks
TypeError: 'str' object is not callable

  • Expression: "python:view.talks()"
  • Filename: ... ite/src/ploneconf/site/browser/templates/talkviewlist.pt
  • Location: (line 15: col 29)
  • Source: ... tbody tal:define="talks python:view.talks()">
  • Arguments: repeat: {...} (0)
    template: <ViewPageTemplateFile - at 0x7f55085f8cd0>
    views: <ViewMapper - at 0x7f5507e77fd0>
    modules: <instance - at 0x7f551312a0e0>
    args: <tuple - at 0x7f551ba29050>
    here: <ImplicitAcquisitionWrapper Plone5 at 0x7f550873f410>
    user: <ImplicitAcquisitionWrapper - at 0x7f550a9608c0>
    nothing: <NoneType - at 0x5585e247d560>
    container: <ImplicitAcquisitionWrapper Plone5 at 0x7f550873f410>
    request: <instance - at 0x7f55084a0710>
    wrapped_repeat: <SafeMapping - at 0x7f5509b3fe10>
    traverse_subpath: <list - at 0x7f5507fb35a8>
    default: <object - at 0x7f551b948550>
    loop: {...} (0)
    context: <ImplicitAcquisitionWrapper Plone5 at 0x7f550873f410>
    view: <SimpleViewClass from /home/ananth/Plone/zinstance/src/ploneconf.site/src/ploneconf/site/browser/templates/talkviewlist.pt talklistview at 0x7f5507e77350>
    translate: <function translate at 0x7f5507fa12a8>
    root: <ImplicitAcquisitionWrapper Zope at 0x7f550a9f22d0>
    options: {...} (0)
    target_language: <NoneType - at 0x5585e247d560>

The browser/configure.xml:



class TalkListView(BrowserView):

def talks(self):

  for brain in brains:
  return results


<tbody tal:define="talks python:view.talks()">


current_path is obviously a string, not a callable


whats the solution. I want the current path. I removed the current path I am getting the same error

The right solution is in https://training.plone.org/5/mastering-plone/views_3.html you made a typo while copying it.

portal_catalog = api.portal.get_tool('portal_catalog')
current_path = '/'.join(self.context.getPhysicalPath())
brains = portal_catalog(path=current_path, portal_type='talk')

So: No brackets after current_path since that is a string and not a callable.

I got the solution

I have included the
layer=zope.inerface.Interface in configure.zcml
After removing and restarting zope . I got the result.

Can anyone explain what is the use of layer

thanks man for the solution

Layers are marker interfaces applied to the HTTPRequest object. They are usually used in conjunction with ZCML directives to dynamically activate various parts of the configuration (theme files, add-on product functionality).

From: https://docs.plone.org/develop/plone/views/layers.html#introduction

This was never ever the solution to your problem.

Ya I know . The current_path() is the problem . I didnt have the interface.py thats another problem.

Again, your statements make are completely unrelated and make no sense in the context of the original question and the original error.