I am using nextURL() in a similar fashion (only using create(),
no add part) and it works fine for me, i. e. I am redirected as
expected, see the code snippet below.

I guess with the line

    self.context[data["title"]] = self.link

your are trying to add the object. - This is just my guess: 
You might try to add
  
    self._finished_add = True

as in the original code for add() and/or even use 

    zope.event.notify(ObjectCreatedEvent(ob))

as in the original code for createAndAdd().

This is what works for me:

    class addView(form.AddForm):

        form_fields = form.Fields(IAdr)

        template = namedtemplate.NamedTemplate('af')

        label=u'Adresse Hinzufügen'

        def setUpWidgets(self, ignore_request=False):
            super(addView, self).setUpWidgets(ignore_request=ignore_request)
            inWs(self.widgets)

        def create(self, data):
            """..."""
            a = Adr()
            for k in data.keys():
                setattr(a, k, data[k])
            # für nextURL() später
            self.a=a
            return a

        # quasi redirect
        def nextURL(self):
            return absoluteURL(self.a, self.request)

        # "Speichern"
        actions=form.AddForm.actions[:]
        actions[u'actions.add'].label=u'Speichern'


On Mon, Aug 07, 2006 at 04:03:53PM +0200, Florian Lindner wrote:
> Hello,
> I habe a view class derived from zope.formlib.form.AddForm:
> 
> class AddLink(form.AddForm):
>     form_fields = form.fields(ILink)
>     
>     def createAndAdd(self, data):
>         self.link = Link()
>         self.link.title = data['title']
>         self.link.description = data['description']
>         self.link.URL = data['URL']
>         
>         self.context[data["title"]] = self.link
>         
>         return self.link
>     
>     def nextURL(self):
>         return absoluteURL(self.link, self.request)
> 
> The view is registered for "zope.app.container.interfaces.IAdding"
> 
> After I have added the object I except to be redirected to the URL returned 
> in 
> nextURL. Instead I am always redirected to the add form again. It seems that 
> nextURL is not even called. Why?
> 
> Thanks,
> 
> Florian
> _______________________________________________
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 
> 
> !DSPAM:44d74b92206451637432971!
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to