Thanks Jim,
 I now get the page back with the right data. I now have to figure out how to 
have the actions work.
 I guess I'll have to ajaxify my page in order to pass the data and have the 
form do it's work. 
 I'll let you know if I encounter further problems or if it works (hopefully).

----- Message d'origine ----
De : Jim Washington <[EMAIL PROTECTED]>
À : Stéphane Brault <[EMAIL PROTECTED]>
Cc :
Envoyé le : Mercredi, 19 Avril 2006, 6h10mn 35s
Objet : Re: Re : Re : [Zope3-Users] formlib problem

Stéphane Brault wrote:
> Hi Jim, 
>  the Items object is my object, linked to my items, table which implements 
> the IItems interface I use for my form:
>  from neteven.interfaces.items import IItems
>  from zope.formlib import form    
>  class ItemsForm(form.EditForm):
>      form_fields = form.Fields(IItems)
>      form_fields = form_fields.omit('dateLastUpdate')
>  Items is defined this way:
>  from zope.interface import implements
>  from sqlobject import *
>  from sqlos import SQLOS
>  from neteven.interfaces.items import IItems
>  class Items(SQLOS):
>      implements(IItems)
>      class sqlmeta:
>          table = 'items'
>  ....
>   When I add this zcml declaration :
>  <browser:page
>        for=".interfaces.items.IItems"
>        name="edit.html"
>        class=".forms.items.ItemsForm"
>        menu="zmi_views"
>        title="Edit a Item"
>        permission="zope.ManageContent"
>        />
>  everything works fine from the ZMI (I created simple containers to test 
> that).
>  My JSON server side code is:
>  def getItemEdit(self, itemId):
>          item = Items.get(itemId) #a sqlos function to get an Item instance 
> from the table given its Id
>          return ItemsForm(item, self.request)()
> The fact is I don't use any page template right now ( though I might do this 
> later to have a nice GUI).
Actually, you are using a page template.

Calling ItemsForm() invokes the render() method of 
zope.formlib.form.FormBase, which uses in the zope.formlib 
folder by default.  This is where title_or_id is requested.

You may wish to set a different template for your ItemsForm class.

Have you tried subclassing form.SubPageEditForm instead of form.EditForm?

-Jim Washington

Zope3-users mailing list

Reply via email to