Use an External Method. If the problem is that the existing one does have the limitation of always redirecting to other places that you would like, then start by recreating a working version of that method as a External Method, importing just the modules and stuff that you need. Then you just remove the unwanted line(s). Ausum ----- Original Message ----- From: "John Schinnerer" <johnschinnerer@yahoo.com> To: "zope list" <zope@zope.org> Sent: Friday, April 09, 2004 1:28 PM Subject: Re: [Zope] How do I get product to return other than ZMI page?
Hello again, I'm back with this little tangle...
--- Chris Withers <lists@simplistix.co.uk> wrote:
from the mxm README example, for manage_addAction I am using
def manage_addAction(self, id=None, REQUEST=None) "Add instance to parent ObjectManager"
Will this method ever be the target of a form?
Yes, that's exactly what I'm trying to do with it. That is, use the method to add the object via web form.
The standard idiot\widiom used when calling this kind of stuff in a script is: context.manage_addProduct['myProduct'].manage_addAction(request.id)
...the abscence of a REQUEST is generally taken to mean "don't redirect anywhere". ...you'll probably find mxmObjectManager.addClass() has the other half of the standard idiot init:
if REQUEST is not None: REQUEST.RESPONSE.redirect('somewhere'
...so try not passign the request through...
OK, that makes sense - addClass does this:
if REQUEST is not None: getattr(self, id).manage_changeProperties(REQUEST) return self.manage_main(self, REQUEST)
...so *that's* why I always get the ZMI main frame back, since REQUEST is not None - self.manage_main(self,REQUEST) is inevitably returned.
And - I need to set a bunch of properties when I add the object, and the values for the properties come from the web form - so don't I need to pass REQUEST to make those available? If not, how do I access them? If so, how do I avoid the above return always happening and return the web add form instead?
What I'm trying to do, big picture, is: user goes to web 'add object' form, fills it out, clicks Add, object is added (with properties set as entered in web form), and user is returned to web add form to add another.
I already have this scenario working for editing an existing object. I can simply call an edit method in my product, since the object already exists.
When adding, the object doesn't exist yet, so I can't directly call an add method in my product...so what's the clean and simple way to add an object *and* set properties of it via web form and return to the web form?
thanks, John S.
__________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )