changeset 1335:2cd1b40ea3e7

Added support for deletion of local pages.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sat, 19 Aug 2006 22:53:21 +0200
parents a4efeab7a10f
children bf59bd23289b
files MoinMoin/action/SyncPages.py MoinMoin/wikisync.py docs/CHANGES.aschremmer
diffstat 3 files changed, 30 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/SyncPages.py	Sat Aug 19 22:34:33 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Sat Aug 19 22:53:21 2006 +0200
@@ -212,6 +212,7 @@
 
             local_pagename = rp.local_name
             current_page = PageEditor(self.request, local_pagename) # YYY direct access
+            comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
 
             tags = TagStore(current_page)
 
@@ -238,12 +239,18 @@
                 if rp.local_deleted and rp.remote_deleted:
                     return
                 if rp.remote_deleted and not local_change:
-                    self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r locally" % rp)
-                    # XXX delete rp locally
+                    msg = local.delete_page(rp.local_name, comment)
+                    if not msg:
+                        self.log_status(ActionClass.INFO, _("Deleted page %s locally."), (rp.name, ))
+                    else:
+                        self.log_status(ActionClass.ERROR, _("Error while deleting page %s locally:"), (rp.name, ), msg)
                     return
                 if rp.local_deleted and not remote_change:
-                    self.log_status(ActionClass.ERROR, "Nothing done, I should have deleted %r remotely" % rp)
-                    # XXX delete rp remotely
+                    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, ))
                     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, ))
@@ -324,8 +331,6 @@
             if debug:
                 self.log_status(ActionClass.INFO, raw_suffix="Diff against %r" % new_contents)
 
-            comment = u"Local Merge - %r" % (remote.get_interwiki_name() or remote.get_iwid())
-
             # XXX upgrade to write lock
             try:
                 current_page.saveText(verynewtext, rp.local_rev, comment=comment) # YYY direct access
--- a/MoinMoin/wikisync.py	Sat Aug 19 22:34:33 2006 +0200
+++ b/MoinMoin/wikisync.py	Sat Aug 19 22:53:21 2006 +0200
@@ -18,6 +18,7 @@
 from MoinMoin import wikiutil
 from MoinMoin.util import lock
 from MoinMoin.Page import Page
+from MoinMoin.PageEditor import PageEditor
 from MoinMoin.packages import unpackLine, packLine
 
 
@@ -67,7 +68,7 @@
         assert remote_rev != 99999999
 
     def __repr__(self):
-        return repr("<Remote Page %r>" % unicode(self))
+        return repr("<Sync Page %r>" % unicode(self))
 
     def __unicode__(self):
         return u"%s[%s|%s]<%r:%r>" % (self.name, self.local_name, self.remote_name, self.local_rev, self.remote_rev)
@@ -174,6 +175,10 @@
         """ 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. """
@@ -233,6 +238,9 @@
         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
+
     # Methods implementing the RemoteWiki interface
     def get_interwiki_name(self):
         return self.remote_interwikiname
@@ -293,6 +301,14 @@
     # Public methods:
 
     # Methods implementing the RemoteWiki interface
+    def delete_page(self, page_name, comment):
+        page = PageEditor(self.request, page_name)
+        try:
+            page.deletePage(comment)
+        except PageEditor.AccessDenied, (msg, ):
+            return msg
+        return ""
+
     def get_interwiki_name(self):
         return self.request.cfg.interwikiname
 
--- a/docs/CHANGES.aschremmer	Sat Aug 19 22:34:33 2006 +0200
+++ b/docs/CHANGES.aschremmer	Sat Aug 19 22:53:21 2006 +0200
@@ -2,11 +2,13 @@
 ===============================
 
   Known main issues:
+    * Do I need to tag delete operations?
     * How to handle renames?
     * How will we store tags? (Metadata support would be handy)
       (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.