[Product-Developers] Using template files for zope formlib widgets

Derek Broughton derek at pointerstop.ca
Thu Jun 25 19:21:48 UTC 2009


I'm trying to build a formlib widget that uses the Google Search API to 
return images related to a given field.

I have the Field defined, extending zope.schema.ASCIIline.  I have a widget, 
extending DisplayWidget.  I seem even to be able to hand code the HTML I 
want into the return statement of the Widget's __call__().  I'd like to get 
the HTML out of the python code, though, and into a page template, and that 
I can't do.  Everything I've tried, to use a template results in one or 
another error indicating that the context in which the template is expanded 
is missing _something_ important.

Most commonly, I end up with errors indicating that the "REQUEST" object 
doesn't have an attribute named "other" (see below).

I refuse to believe it isn't possible, but I don't want to tear my hair out, 
so somebody please point me to some useful documentation.

Traceback (innermost last):                                                                                                                                 
  Module ZPublisher.Publish, line 119, in publish                                                                                                           
  Module ZPublisher.mapply, line 88, in mapply                                                                                                              
  Module ZPublisher.Publish, line 42, in call_object                                                                                                        
  Module zope.formlib.form, line 770, in __call__                                                                                                           
  Module zope.formlib.form, line 764, in render                                                                                                             
  Module plone.app.form._named, line 26, in __call__                                                                                                        
  Module Shared.DC.Scripts.Bindings, line 313, in __call__                                                                                                  
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec                                                                                              
  Module Products.PageTemplates.PageTemplateFile, line 129, in _exec                                                                                        
  Module Products.PageTemplates.PageTemplate, line 89, in pt_render                                                                                         
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render                                                                                             
  Module zope.tal.talinterpreter, line 271, in __call__                                                                                                     
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 891, in do_useMacro                                                                                                  
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal                                                                                                
  Module zope.tal.talinterpreter, line 521, in do_optTag                                                                                                    
  Module zope.tal.talinterpreter, line 516, in no_tag                                                                                                       
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 891, in do_useMacro                                                                                                  
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal                                                                                                
  Module zope.tal.talinterpreter, line 521, in do_optTag                                                                                                    
  Module zope.tal.talinterpreter, line 516, in no_tag                                                                                                       
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 957, in do_defineSlot                                                                                                
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal                                                                                                
  Module zope.tal.talinterpreter, line 521, in do_optTag                                                                                                    
  Module zope.tal.talinterpreter, line 516, in no_tag                                                                                                       
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 861, in do_defineMacro                                                                                               
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 949, in do_defineSlot                                                                                                
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal                                                                                                
  Module zope.tal.talinterpreter, line 521, in do_optTag                                                                                                    
  Module zope.tal.talinterpreter, line 516, in no_tag                                                                                                       
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 949, in do_defineSlot                                                                                                
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 861, in do_defineMacro                                                                                               
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 861, in do_defineMacro                                                                                               
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 957, in do_defineSlot                                                                                                
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 534, in do_optTag_tal                                                                                                
  Module zope.tal.talinterpreter, line 516, in no_tag                                                                                                       
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 824, in do_loop_tal                                                                                                  
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal                                                                                                
  Module zope.tal.talinterpreter, line 521, in do_optTag                                                                                                    
  Module zope.tal.talinterpreter, line 516, in no_tag                                                                                                       
  Module zope.tal.talinterpreter, line 346, in interpret                                                                                                    
  Module zope.tal.talinterpreter, line 745, in do_insertStructure_tal                                                                                       
  Module Products.PageTemplates.Expressions, line 221, in evaluateStructure                                                                                 
  Module zope.tales.tales, line 696, in evaluate                                                                                                            
   - URL: pageform                                                                                                                                          
   - Line 109, Column 10                                                                                                                                    
   - Expression: <PathExpr standard:'widget'>                                                                                                               
   - Names:                                                                                                                                                 
      {'container': <OBISInstitution at /Plone/data/science/centre-for-
science-advice/obis-canada/obis-data/ARC>,                                           
       'context': <OBISInstitution at /Plone/data/science/centre-for-
science-advice/obis-canada/obis-data/ARC>,                                             
       'default': <object object at 0xb7e3c530>,                                                                                                            
       'here': <OBISInstitution at /Plone/data/science/centre-for-science-
advice/obis-canada/obis-data/ARC>,                                                
       'loop': {'widget': <Products.PageTemplates.Expressions.PathIterator 
object at 0xfd033ac>},                                                           
       'nothing': None,                                                                                                                                     
       'options': {'args': ()},                                                                                                                             
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 
0xff56d6c>,                                                                      
       'request': <HTTPRequest, URL=http://vdc/data/science/centre-for-
science-advice/obis-canada/obis-data/ARC/@@distribution>,
       'root': <Application at >,
       'template': <ImplicitAcquirerWrapper object at 0xfef35cc>,
       'traverse_subpath': [],
       'user': <PloneUser 'broughtond'>,
       'view': <Products.Five.metaclass.SimpleViewClass from 
/home/derek/plone/VDC/src/obiscanada/Products/obiscanada/browser/templates/DistributionView.ptobject 
at 0x10484f8c>,
       'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper 
object at 0xff56bec>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 161, in _eval
  Module Products.PageTemplates.Expressions, line 123, in render
  Module Products.obiscanada.browser.widgets, line 100, in __call__
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Shared.DC.Scripts.Bindings, line 1, in ?
  Module Shared.DC.Scripts.Bindings, line 293, in _getTraverseSubpath
AttributeError: 'str' object has no attribute 'other'


-- 
derek






More information about the Product-Developers mailing list