[Zope3-Users] Widget Error on direct __call__ with pt

Dennis Schulz d.schulz81 at gmx.net
Thu Dec 7 05:49:58 EST 2006


Hello,


I am using the following code for a sequence widget.


class TableRecordSequenceWidget(ListSequenceWidget):
    def __init__(self, context, field, request, template_='', 
subwidget=None):
        super(TableRecordSequenceWidget, self).__init__(
            context, field, request, subwidget)
    def __call__(self):
       .... render sth........


It works good as long as I write the rendered html directly in the 
__call__ method.
But after a while it gets dirty, I would like to have it in a page 
template......

However when I try to change it to return a page template in the call 
method,

(like I found it in many examples)

    def __call__(self):
        class TemplateObjectWidgetView(ObjectWidgetView):
            template = ZopeTwoPageTemplateFile("itemwidget.pt")
        template = TemplateObjectWidgetView(self, self.request)
        return template()

I have the following error:

Any help? Again, the version without the page template works perfectly

            <td tal:define="widget python:view.widgets.get('items')"  >
                 <div class="CellsTableRowListHeader" 
tal:content="structure widget"></div>
            </td>


  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module zope.formlib.form, line 898, in __call__
  Module zope.formlib.form, line 892, in render
  Module Shared.DC.Scripts.Bindings, line 311, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Products.PageTemplates.PageTemplateFile, line 113, in _exec
  Module Products.PageTemplates.PageTemplate, line 104, in pt_render
   - <ImplicitAcquirerWrapper object at 0x05BA8110>
  Module TAL.TALInterpreter, line 238, in __call__
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 749, in do_useMacro
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 457, in do_optTag_tal
  Module TAL.TALInterpreter, line 442, in do_optTag
  Module TAL.TALInterpreter, line 437, in no_tag
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 749, in do_useMacro
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 457, in do_optTag_tal
  Module TAL.TALInterpreter, line 442, in do_optTag
  Module TAL.TALInterpreter, line 437, in no_tag
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 780, in do_defineSlot
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 457, in do_optTag_tal
  Module TAL.TALInterpreter, line 442, in do_optTag
  Module TAL.TALInterpreter, line 437, in no_tag
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 728, in do_defineMacro
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 772, in do_defineSlot
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 728, in do_defineMacro
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 780, in do_defineSlot
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 772, in do_defineSlot
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 749, in do_useMacro
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 457, in do_optTag_tal
  Module TAL.TALInterpreter, line 442, in do_optTag
  Module TAL.TALInterpreter, line 437, in no_tag
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 780, in do_defineSlot
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 457, in do_optTag_tal
  Module TAL.TALInterpreter, line 442, in do_optTag
  Module TAL.TALInterpreter, line 437, in no_tag
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 749, in do_useMacro
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 457, in do_optTag_tal
  Module TAL.TALInterpreter, line 442, in do_optTag
  Module TAL.TALInterpreter, line 437, in no_tag
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 749, in do_useMacro
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 457, in do_optTag_tal
  Module TAL.TALInterpreter, line 442, in do_optTag
  Module TAL.TALInterpreter, line 437, in no_tag
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 647, in do_insertStructure_tal
  Module Products.PageTemplates.TALES, line 221, in evaluate
   - URL: index
   - Line 286, Column 4
   - Expression: standard:'widget'
   - Names:
      {'container': <PurchaseRequisition at 
/Plone/purchaserequisition.2006-11-29.5884219316/pr/196>,
       'context': <PurchaseRequisition at 
/Plone/purchaserequisition.2006-11-29.5884219316/pr/196>,
       'default': <Products.PageTemplates.TALES.Default instance at 
0x017EB5F8>,
       'here': <PurchaseRequisition at 
/Plone/purchaserequisition.2006-11-29.5884219316/pr/196>,
       'loop': <Products.PageTemplates.TALES.SafeMapping object at 
0x05BAB440>,
       'modules': 
<Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 
0x017D8B48>,
       'nothing': None,
       'options': {'args': ()},
       'repeat': <Products.PageTemplates.TALES.SafeMapping object at 
0x05BAB440>,
       'request': <HTTPRequest, 
URL=http://localhost:8080/Plone/purchaserequisition.2006-11-29.5884219316/pr/196/predit>,
       'root': <Application at >,
       'template': <ImplicitAcquirerWrapper object at 0x05BA8110>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'mugdiman'>,
       'view': <Products.Five.metaclass.PREditView object at 0x05B89C50>,
       'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper 
object at 0x05BA82D0>}
  Module Products.PageTemplates.Expressions, line 185, in __call__
  Module Products.PageTemplates.Expressions, line 180, in _eval
  Module Products.PageTemplates.Expressions, line 85, in render
  Module Products.PurchaseRequisition.browser.objectwidget, line 386, in 
__call__
  Module zope.app.form.browser.objectwidget, line 41, in __call__
  Module Shared.DC.Scripts.Bindings, line 311, in __call__
  Module Shared.DC.Scripts.Bindings, line 346, in _bindAndExec
  Module Shared.DC.Scripts.Bindings, line 1, in ?
  Module Shared.DC.Scripts.Bindings, line 291, in _getTraverseSubpath
AttributeError: 'str' object has no attribute 'other'



More information about the Zope3-users mailing list