Hello,
I have created a product using mxmObjectManager as a base. I have a web form so a client can add these objects to folders from outside the ZMI. It works, but always returns the ZMI manage_main page (without left nav frame) for the folder the object was added to. Instead, I want to return to the empty 'add object' web form to add another. The web form invokes a python script to get to the manage_addAction method in the product:
# pertinent pythonscript code
request = container.REQUEST RESPONSE = request.RESPONSE
context.manage_addProduct['myProduct'].manage_addAction(request.id,request)
from the mxm README example, for manage_addAction I am using
def manage_addAction(self, id=None, REQUEST=None) "Add instance to parent ObjectManager" mxmObjectManager.addClass(self, id, myProduct, REQUEST)
...plus it then sets properties of the added object and creates some StructuredDocument objects inside the added object. That all works fine. However...
No matter what code I put in to try and return something else - at the end of manage_addAction or in the python script that calls it - the result is that the ZMI manage_main page is what I always get back.
I'm guessing that the manage_addProduct['myProduct'] in the script is somehow hijacking the return from manage_addAction and returning the ZMI page...??
If so, and in any case, how can I return something other than that, like the web form again?
thanks, John S.
__________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html
What is mxmObjectManager? Where can I download and read about this? Creation products objects to folders from outside the ZMI is interesting for me.
Regard, Serg
Serg wrote:
What is mxmObjectManager?
I think the webpage for that product will explain it.
Where can I download and read about this?
Search zope.org
Creation products objects to folders from outside the ZMI is interesting for me.
The ZMI is not a magic environment, but a web application like any other. You may use it for an example. See also zopelabs.com for recipes.
--jcc
Hello,
--- Serg sutni@yandex.ru wrote:
What is mxmObjectManager? Where can I download and read about this?
Go here to read about and download this zope product by maxm:
http://zope.org/Members/maxm/index_html/HowTo/easyProduct
It provdes both a simple object and a simple object manager class that you can use as base classes for your own products. So far I find it very handy (I am pretty new at building my own products).
It only supports DTML as it is, so if you are using page templates you will need to add this import to your products based on mxmSimpleItem or mxmObjectManager:
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
and when defining your web methods you use (example for index_html):
index_html = PageTemplateFile('www/index_html', globals())
instead of:
index_html = HTMLFile('www/index_html', globals())
as you would with DTML.
cheers, John S.
__________________________________ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html
John Schinnerer wrote:
request = container.REQUEST RESPONSE = request.RESPONSE
context.manage_addProduct['myProduct'].manage_addAction(request.id,request)
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".
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?
I'm guessing that the manage_addProduct['myProduct'] in the script is somehow hijacking the return from manage_addAction and returning the ZMI page...??
Nah ,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...
cheers,
Chris
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/
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 )
Hello,
--- Ausum Studio ausum_studio@hotmail.com wrote:
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).
It's my own product, so can't I just change what is being done within my product, without having to use an external method?
I need to see an example of how to programmatically add an object to a folder and set its properties via a web form instead of the ZMI, and return the form again instead of the ZMI, in a product I create myself. Can't find anything in Zope Bible, or online searches so far, that shows that.
thanks, John S.
__________________________________ Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html
#Script name: "product_creater", meaning the form itself.
def manage_addAction(self, REQUEST): "Add instance to parent ObjectManager" context.manage_addProduct['myProduct'].manage_addAction(REQUEST.id) objectjustcreated = getattr(context, REQUEST.id)
#property changes: Use as many sentences as you need objectjustcreated.manage_changeProperties(title=REQUEST.title)
REQUEST.RESPONSE.redirect(context.absolute_url() + '/product_creater')
Note that REQUEST can't be None and that you don't need the 'id' parameter, as it will arrive with the REQUEST, unless you want your script to function programatically (no forms involved). In fact, the REQUEST=None thing is meant to be used for those cases.
Ausum
----- Original Message ----- From: "John Schinnerer" johnschinnerer@yahoo.com To: "zope list" zope@zope.org Sent: Sunday, April 11, 2004 12:26 AM Subject: Re: [Zope] How do I get product to return other than ZMI page?
Hello,
--- Ausum Studio ausum_studio@hotmail.com wrote:
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).
It's my own product, so can't I just change what is being done within my product, without having to use an external method?
I need to see an example of how to programmatically add an object to a folder and set its properties via a web form instead of the ZMI, and return the form again instead of the ZMI, in a product I create myself. Can't find anything in Zope Bible, or online searches so far, that shows that.
thanks, John S.
Do you Yahoo!? Yahoo! Tax Center - File online by April 15th http://taxes.yahoo.com/filing.html
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 )
Hello,
Thank you!! :-)
This...
REQUEST.RESPONSE.redirect(context.absolute_url() +
'/product_creater')
Is the missing link bit of syntax/detail I've needed. It works just the way I need now. I guess it's the same conceptuall as Bill H.'s reply (thanks Bill!) but the instance.aq_parent part of that example didn't work for me and I didn't know why or what to change it to.
Mahalo, John S
--- Ausum Studio ausum_studio@hotmail.com wrote:
#Script name: "product_creater", meaning the form itself.
def manage_addAction(self, REQUEST): "Add instance to parent ObjectManager"
context.manage_addProduct['myProduct'].manage_addAction(REQUEST.id) objectjustcreated = getattr(context, REQUEST.id)
#property changes: Use as many sentences as you need objectjustcreated.manage_changeProperties(title=REQUEST.title) REQUEST.RESPONSE.redirect(context.absolute_url() +
'/product_creater')
Note that REQUEST can't be None and that you don't need the 'id' parameter, as it will arrive with the REQUEST, unless you want your script to function programatically (no forms involved). In fact, the REQUEST=None thing is meant to be used for those cases.
Ausum
__________________________________ Do you Yahoo!? Yahoo! Small Business $15K Web Design Giveaway http://promotions.yahoo.com/design_giveaway/