[CMF-checkins] CVS: CMF/CMFWiki/skins/wiki - wikipage_deleterename_handler.py:1.2

Ken Manheimer klm@zope.com
Tue, 5 Feb 2002 16:28:38 -0500


Update of /cvs-repository/CMF/CMFWiki/skins/wiki
In directory cvs.zope.org:/tmp/cvs-serv30142

Modified Files:
	wikipage_deleterename_handler.py 
Log Message:
After deleting a page, try to return to its (first) parent.


=== CMF/CMFWiki/skins/wiki/wikipage_deleterename_handler.py 1.1 => 1.2 ===
         raise ValueError, ("You must check the 'confirm delete'"
                            " box to commit the deletion.")
-    context.delete()
     url = REQUEST.get('URL2') + '/FrontPage'
+
+    # Try to get a parent url, so we can return there
+    folder = context.aq_parent
+    for p in context.parents:
+        if hasattr(folder, p):
+            url = folder[p].wiki_page_url()
+            break
+
+    context.delete()
     
 elif REQUEST.has_key('Rename'):
     url = context.rename(REQUEST.get('new_id'))
     
-RESPONSE.redirect('%s' % url)
\ No newline at end of file
+RESPONSE.redirect('%s' % url)