changeset 1343:144c3281e88f

Now the deletion of remote pages is working.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sun, 20 Aug 2006 15:49:12 +0200
parents b8ee9f0cb30e
children 564cc2b53ea9
files MoinMoin/action/SyncPages.py MoinMoin/wikisync.py MoinMoin/xmlrpc/__init__.py docs/CHANGES.aschremmer
diffstat 4 files changed, 32 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/SyncPages.py	Sun Aug 20 13:48:16 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Sun Aug 20 15:49:12 2006 +0200
@@ -48,7 +48,6 @@
         self.pagename = pagename
         self.page = PageEditor(request, pagename)
         self.status = []
-        request.flush()
 
     def log_status(self, level, message="", substitutions=(), raw_suffix=""):
         """ Appends the message with a given importance level to the internal log. """
@@ -147,7 +146,7 @@
         self.page.saveText(self.page.get_raw_body() + "\n\n" + self.generate_log_table(), 0)
         # XXX release readlock on self.page
 
-        return self.page.send_page(self.request, msg=msg)
+        self.page.send_page(self.request, msg=msg)
     
     def sync(self, params, local, remote):
         """ This method does the syncronisation work.
@@ -249,9 +248,11 @@
                 if rp.local_deleted and not remote_change:
                     if direction == DOWN:
                         return
-                    self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r remotely" % rp) # XXX add
-                    msg = remote.delete_page(rp.remote_name)
-                    self.log_status(ActionClass.INFO, _("Deleted page %s remotely."), (rp.name, ))
+                    msg = remote.delete_page(rp.remote_name, rp.remote_rev, local_full_iwid)
+                    if not msg:
+                        self.log_status(ActionClass.INFO, _("Deleted page %s remotely."), (rp.name, ))
+                    else:
+                        self.log_status(ActionClass.ERROR, _("Error while deleting page %s remotely:"), (rp.name, ), msg)
                     return
                 if rp.local_mime_type != MIMETYPE_MOIN and not (local_change ^ remote_change):
                     self.log_status(ActionClass.WARN, _("The item %s cannot be merged but was changed in both wikis. Please delete it in one of both wikis and try again."), (rp.name, ))
--- a/MoinMoin/wikisync.py	Sun Aug 20 13:48:16 2006 +0200
+++ b/MoinMoin/wikisync.py	Sun Aug 20 15:49:12 2006 +0200
@@ -155,10 +155,6 @@
         """ Returns a list of SyncPage instances. """
         return NotImplemented
 
-    def delete_page(self, pagename):
-        """ Deletes the page called pagename. """
-        return NotImplemented
-
 
 class MoinRemoteWiki(RemoteWiki):
     """ Used for MoinMoin wikis reachable via XMLRPC. """
@@ -218,10 +214,17 @@
         result = self.connection.mergeDiff(pagename, xmlrpclib.Binary(diff), local_rev, delta_remote_rev, last_remote_rev, interwiki_name, n_name)
         return result
 
-    def delete_page(self, pagename):
-        return # XXX not implemented yet
+    def delete_page(self, pagename, last_remote_rev, interwiki_name):
+        try:
+            result = self.connection.mergeDiff(pagename, None, None, None, last_remote_rev, interwiki_name, None)
+        except xmlrpclib.Fault, e:
+            if e.faultCode == "NOT_ALLOWED":
+                return e.faultString
+            raise
+        return ""
 
     # Methods implementing the RemoteWiki interface
+
     def get_interwiki_name(self):
         return self.remote_interwikiname
 
@@ -281,7 +284,7 @@
     # Public methods:
 
     # Methods implementing the RemoteWiki interface
-    def delete_page(self, page_name, comment):
+    def delete_page(self, pagename, comment):
         page = PageEditor(self.request, page_name)
         try:
             page.deletePage(comment)
--- a/MoinMoin/xmlrpc/__init__.py	Sun Aug 20 13:48:16 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Sun Aug 20 15:49:12 2006 +0200
@@ -698,11 +698,19 @@
             
             @param pagename: The pagename that is currently dealt with.
             @param diff: The diff that can be applied to the version specified by delta_remote_rev.
+                If it is None, the page is deleted.
             @param local_rev: The revno of the page on the other wiki system, used for the tag.
             @param delta_remote_rev: The revno that the diff is taken against.
             @param last_remote_rev: The last revno of the page `pagename` that is known by the other wiki site.
             @param interwiki_name: Used to build the interwiki tag.
             @param normalised_name: The normalised pagename that is common to both wikis.
+            
+            @return Returns the current revision number after the merge was done. Or one of the following errors:
+                * "SUCCESS" - the page could be merged and tagged successfully.
+                * "NOT_EXIST" - item does not exist and there was not any content supplied.
+                * "LASTREV_INVALID" - the page was changed and the revision got invalid
+                * "INTERNAL_ERROR" - there was an internal error
+                * "NOT_ALLOWED" - you are not allowed to do the merge operation on the page
         """
         from MoinMoin.util.bdiff import decompress, patch
         from MoinMoin.wikisync import TagStore, BOTH
@@ -728,6 +736,13 @@
         if not currentpage.exists() and diff is None:
             return xmlrpclib.Fault("NOT_EXIST", "The page does not exist and no diff was supplied.")
 
+        if diff is None: # delete the page
+            try:
+                currentpage.deletePage(comment)
+            except PageEditor.AccessDenied, (msg, ):
+                return xmlrpclib.Fault("NOT_ALLOWED", msg)
+            return currentpage.get_real_rev()
+
         # base revision used for the diff
         basepage = Page(self.request, pagename, rev=(delta_remote_rev or 0))
 
--- a/docs/CHANGES.aschremmer	Sun Aug 20 13:48:16 2006 +0200
+++ b/docs/CHANGES.aschremmer	Sun Aug 20 15:49:12 2006 +0200
@@ -8,7 +8,6 @@
       (currently done in Pickle files)
 
   ToDo:
-    * Delete remote pages.
     * Reduce round-trip times by caching queries and using MultiCall objects (coroutines?)
     * Check what needs to be documented on MoinMaster.
 
@@ -16,9 +15,8 @@
 
     * Test with prefixes
     * Search for XXX
-    * Delete iters?
     * Maybe refactor YYY into MoinLocalWiki
-    * Remove amount of "very" in the code
+    * Remove amount of "very" in the code, rename rp into sp
     * Clean up trailing whitespace.
 
     * Implement a cross-site authentication system, i.e. mainly an