[Zope3-Users] custom widgets (IDisplayWidget)

Hassan Alirezaei hassan at isi.imi.i.u-tokyo.ac.jp
Sat Nov 25 11:01:52 EST 2006


Hi Kapil , Thanks for the reply.
> part of it depends not only registration of the custom display widget, 
> but also how your rendering the display, ie. if your using formlib, 
> just using a displayformbase should do it, if your using zope.app.form 
> directly you'll might also need to specify that you want to specify 
> IDisplayWidget as the type when rendering, ie. its hard to say without 
> the other piece of this, namely how your rendering the form.
I am not using formlib. I use just the normal auto-generated forms for 
schema using the following zcml :

  <addform
      label="Add Paper(Conf)"
      name="AddPaper.html"
      schema="..interfaces.IPaper"
      content_factory="..paper.Paper"
      fields="something"
      permission="paper.edit"
      />

  <page
      for="..interfaces.IPaper"
      name="paper.html"
      template="paper.pt"
      permission="zope.Public"
      menu="zmi_views" title="Preview"
      />

and the schema itself is like this:

    class IPaper(IPublication):
        """A conference paper"""  
   
        something=I18N(
            title=u"something",
            description=u"the title of the paper in English",
            value_type=TextLine(title=u"value")
        )

and then after adding the object I use the following line in my template 
file (paper.pt) to render it:

<span tal:content="context/something">some</span>



I register the I18N widget like this:

    <zope:view type="zope.publisher.interfaces.browser.IBrowserRequest"
        provides="zope.app.form.interfaces.IInputWidget"
        for="..interfaces.II18N"
        factory=".widgets.SimpleI18NInputWidget"
        permission="zope.Public" />


    <zope:view type="zope.publisher.interfaces.browser.IBrowserRequest"
        provides="zope.app.form.interfaces.IDisplayWidget"
        for="..interfaces.II18N"
        factory=".widgets.I18NSimpleDisplayWidget"
        permission="zope.Public"
        name="myview"/>


now, the I18N widget renders fine at the time of adding the object (the 
view for IInputWidget) but it the other view to IDisplayWidget which is 
for display time (the zpt tag) will not even call the __call__() method 
of the I18NSimpleDisplayWidget class which is confusing.

Do I need to have some other kind of setting???? please help.

thanks,
Hass











More information about the Zope3-users mailing list