Override a redirection in response
Hello, I'm trying to "veneer" the ZMI's rename form. Everything works util an error is rised (i.e. rename a file to an existing file name); the manage_renameObject() method in CopySupport.py then redirects to manage_main: try: ob._notifyOfCopyTo(self, op=1) except: raise CopyError, MessageDialog( title='Invalid Id', message=sys.exc_info()[1], action ='manage_main') <- why isn't this conditioned? (i.e.) to the existence of a certain variable, as in ... if REQUEST is not None: return self.manage_main(self, REQUEST, update_menu=1) return None Trying to catch the exception is in vain, the redirect remains. So, is there anyway to catch this exception or at least to remove the redirect from the RESPONSE? This is my code so far: <dtml-try> <dtml-with "REQUEST.resolve_url(path_to_container)"> <dtml-call "manage_renameObject(ids_item, new_ids_item)"> <- kaput </dtml-with> <dtml-except CopyError> <- doesn't work, redirect remains. <dtml-call "errIds.append(ids_item)"> </dtml-try> ... <dtml-call "RESPONSE.redirect(URL1)"> <- ha, ha, ha ... Thanks for your help, Pablo.
Pablo Ziliani writes:
I'm trying to "veneer" the ZMI's rename form. Everything works util an error is rised (i.e. rename a file to an existing file name); the manage_renameObject() method in CopySupport.py then redirects to manage_main:
try: ob._notifyOfCopyTo(self, op=1) except: raise CopyError, MessageDialog( title='Invalid Id', message=sys.exc_info()[1], action ='manage_main') <- why isn't this conditioned? (i.e.) to the existence of a certain variable, as in ... Trying to catch the exception is in vain, the redirect remains. So, is there anyway to catch this exception or at least to remove the redirect from the RESPONSE? There are redirections that cannot be reverted (they are locked).
But in the section "5.2 Programmatic Management" of <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> you can read that sometimes you may get rid of a redirection by calling "RESPONSE.setStatus(200)". Dieter
participants (2)
-
Dieter Maurer -
Pablo Ziliani