[Zope3-Users] How to redirect to a view after adding an object

Dominik Huber dominik.huber at perse.ch
Mon Oct 31 03:11:33 EST 2005


Martin Margo wrote:

>Hello
>
>Sorry if this was asked before. I did some basic search and couldn't
>find anything. I am new to Zope3 myself.
>
>After reading Stephan and Von Weitershausen's book on Zope 3, I begin
>building my own web application. My question is :
>
>After my user adds a new custom object (type CandyBar) through
>http://<site>/+/AddCandyBar.html=,   how do I redirect the user to a
>custom view (the custom view is called
>browser/CandyBarPurchaseConfirm.pt)?
>  
>
Do you use browser:addform of the form framework?

If so, you have to provide your own view class overwriting the nextURL 
method. Be careful your view is used for the adaption of '+' (the adding 
view of the container). Therefore the self.context is referencing the 
'+' and the self.context.context the underlying container:

class AddView(object):

    def nextURL(self):
        return zapi.absoluteURL(self.context.context, self.request) + 
'/@@anyurl.html'

<browser:addform
    class="module.AddView"
    ...
    />

Regards,
Dominik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dominik.huber.vcf
Type: text/x-vcard
Size: 154 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20051031/8da8fb58/dominik.huber.vcf


More information about the Zope3-users mailing list