[Grok-dev] Re: About interfaces

Santiago Videla santiago.videla at gmail.com
Tue Sep 18 20:33:09 EDT 2007


On 9/18/07, Martijn Faassen <faassen at startifact.com> wrote:
>
> Hey,
>
> Santiago Videla wrote:
> [snip]
> >
> > client.py
> >
> > class Client(grok.Container ):
> >     implements(IPerson, IClient)
> >
> > Thie works fine.
> >
> > But I'm trying to use this:
> > in interfaces.py
> > class IClient(IPerson)
> >    ...
> > in client.py
> > class Client(grok.Container):
> >     implements(IClient)
> >
> > but when I try to edit a client instance i get this:
> >
> >   File "/home/sancho/buildout-eggs/grok-0.10-py2.4.egg/grok/formlib.py",
> > line 18, in success
> >     return self.success_handler(self.form, **data)
> >   File "/home/sancho/revoluciones/proyectos/sac/Sac/src/sac/client.py",
> > line 109, in save
> >     self.applyData(self,**data)
> >   File
> [...]
> > TypeError: ('Could not adapt', <sac.client.EditClient object at
> > 0x99de3ac>, <InterfaceClass sac.interfaces.IPerson>)
>
> Can you show us this sac.client.EditClient class?


Hey,

in client.py, I defined

class EditClient(grok.EditForm):
    grok.context(Client)
    grok.name('edit')
    form_fields = grok.AutoFields(Client)
    template = grok.PageTemplateFile('form.pt')
    form_title = u'Edit client'

    @grok.action("Save")
    def save(self, **data):
        self.applyData(self,**data)
        self.redirect(self.url(self.context))

And I also have

class AddClient(grok.AddForm):
    grok.context(ClientsContainer)

    form_fields = grok.AutoFields(Client)
    template = grok.PageTemplateFile('form.pt')
    form_title = u'Add client'

    @grok.action("Add client")
    def add(self, **data):
        client = Client()
        self.applyData(client, **data)
        name = INameChooser(self.context).chooseName('client', client)
        self.context[name] = client
        self.redirect(self.url(self.context))

the AddClient form works fine using

class IClient(IPerson)

class Client(grok.Container ):
    implements(IClient)

but when I go to edit, i get the error

thanks in advance

Regards,
>
> Martijn
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
>



-- 
Santiago Videla
www.revolucionesweb.com.ar

Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el
pensamiento que se hace corazón resplandece con la palabra sencilla y
humilde que l at s tod at s somos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20070918/ebbbfc74/attachment.htm


More information about the Grok-dev mailing list