[Zope-dev] Redirecting from the manage interfaces.
Erik Enge
erik@src.no
Sat, 15 Jul 2000 16:40:08 +0200 (CEST)
Hi.
I've been browsing through the Zope and Zope-dev archives without finding
anything related to this, please stop me if it has already been dealt
with. :)
technical person = someone who doesn't mind fuzzing around with the
manage_main pages
non-technical person = someone who needs everything in bright nice colors
and would start crying if they saw the manage_main
page, or anything similar.
I have a Product that allows a customer of mine to add some nice pictures
(Image object) to a folder. The add-method is nice and doesn't display
any horrible technical information. I wasn't very keen on making a
add-method for both the technical person and the non-technical person, so
I hacked the source code a bit. I changed the the lib/python/OFS/Image.py
It used to look like this:
"""
def manage_addImage(self, id, file, title='', precondition='',
content_type='', REQUEST=None):
[...]
if REQUEST is not None:
try: url=self.DestinationURL()
except: url=REQUEST['URL1']
REQUEST.RESPONSE.redirect('%s/manage_main' % url)
return id
"""
Which I changed into:
"""
def manage_addImage(self, id, file, title='', precondition='',
content_type='', REQUEST=None, redir=None):
[...]
if redir is not None:
REQUEST.RESPONSE.redirect('%s' % redir)
elif REQUEST is not None:
try: url=self.DestinationURL()
except: url=REQUEST['URL1']
REQUEST.RESPONSE.redirect('%s/manage_main' % url)
"""
Now I can redirect the victim... erm.. customer to the method I want to,
and they are pleased that they don't have to see the management interface.
This saves me a lot of time, since I don't have to make several
add-methods, and maintainace is a more joyable happening. :)
This 'redir' thing is something I've stuck into a lot of .py files
(for example, I use it in the manage_delObjects and others). And
it is something I do every time a new Zope release comes out. Could this
be to any use for anybody besides me? And if it could, how about adding
it to the next release?