diff idavoll/backend.py @ 209:7f3ffb7a1a9e

Add support for node deletion with redirect.
author Ralph Meijer <ralphm@ik.nu>
date Fri, 30 Jan 2009 14:35:05 +0000
parents 274a45d2a5ab
children bfc198af5d27
line wrap: on
line diff
--- a/idavoll/backend.py	Tue Sep 09 14:54:33 2008 +0000
+++ b/idavoll/backend.py	Fri Jan 30 14:35:05 2009 +0000
@@ -434,20 +434,23 @@
         return d
 
 
-    def deleteNode(self, nodeIdentifier, requestor):
+    def deleteNode(self, nodeIdentifier, requestor, redirectURI=None):
         d = self.storage.getNode(nodeIdentifier)
         d.addCallback(_getAffiliation, requestor)
-        d.addCallback(self._doPreDelete)
+        d.addCallback(self._doPreDelete, redirectURI)
         return d
 
 
-    def _doPreDelete(self, result):
+    def _doPreDelete(self, result, redirectURI):
         node, affiliation = result
 
         if affiliation != 'owner':
             raise error.Forbidden()
 
-        d = defer.DeferredList([cb(node.nodeIdentifier)
+        data = {'nodeIdentifier': node.nodeIdentifier,
+                'redirectURI': redirectURI}
+
+        d = defer.DeferredList([cb(data)
                                 for cb in self._callbackList],
                                consumeErrors=1)
         d.addCallback(self._doDelete, node.nodeIdentifier)
@@ -561,11 +564,14 @@
                                                                notifications))
 
 
-    def _preDelete(self, nodeIdentifier):
+    def _preDelete(self, data):
+        nodeIdentifier = data['nodeIdentifier']
+        redirectURI = data.get('redirectURI', None)
         d = self.backend.getSubscribers(nodeIdentifier)
         d.addCallback(lambda subscribers: self.notifyDelete(self.serviceJID,
                                                             nodeIdentifier,
-                                                            subscribers))
+                                                            subscribers,
+                                                            redirectURI))
         return d