changeset 1348:36dec228a83f

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 20 Aug 2006 17:00:17 +0200
parents b65614f8a393 (current diff) baafe28d8037 (diff)
children 4a71075e6d39 26949e36ca0b
files
diffstat 5 files changed, 56 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/SyncPages.py	Sun Aug 20 16:59:51 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Sun Aug 20 17:00:17 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,13 +146,13 @@
         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.
-            Currently, it handles the case where the pages exist on both sides.
-            One of the major missing parts is rename handling.
-            Now there are a few other cases left that have to be implemented:
+            Currently, it handles nearly all cases.
+            The major missing part is rename handling.
+            There are a few other cases left that have to be implemented:
                 Wiki A    | Wiki B   | Remark
                 ----------+----------+------------------------------
                 exists    | non-     | Now the wiki knows that the page was renamed.
@@ -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, ))
@@ -365,3 +366,4 @@
 
 def execute(pagename, request):
     ActionClass(pagename, request).render()
+
--- a/MoinMoin/support/htmlmarkup.py	Sun Aug 20 16:59:51 2006 +0200
+++ b/MoinMoin/support/htmlmarkup.py	Sun Aug 20 17:00:17 2006 +0200
@@ -1,7 +1,8 @@
 # -*- coding: utf-8 -*-
-# copied from trac.util.markup, revision 3446, merged on 2006-06-30
+# copied from trac.util.html, revision 3609, merged on 2006-08-20
 #
 # Copyright (C) 2003-2006 Edgewall Software
+# Copyright 2006 MoinMoin:AlexanderSchremmer
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
@@ -318,8 +319,11 @@
             else:
                 yield escape(child, quotes=False)
 
+    def __unicode__(self):
+        return u''.join(self.serialize())
+
     def __str__(self):
-        return Markup(''.join(self.serialize()))
+        return ''.join(self.serialize())
 
     def __add__(self, other):
         return Fragment()(self, other)
--- a/MoinMoin/wikisync.py	Sun Aug 20 16:59:51 2006 +0200
+++ b/MoinMoin/wikisync.py	Sun Aug 20 17:00:17 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)
@@ -318,15 +321,15 @@
         return "<MoinLocalWiki>"
 
 
-# ------------------ Tags ------------------ 
+# ------------------ Tags ------------------
 
 
 class Tag(object):
     """ This class is used to store information about merging state. """
-    
+
     def __init__(self, remote_wiki, remote_rev, current_rev, direction, normalised_name):
         """ Creates a new Tag.
-        
+
         @param remote_wiki: The identifier of the remote wiki.
         @param remote_rev: The revision number on the remote end.
         @param current_rev: The related local revision.
@@ -390,7 +393,7 @@
 
     def __init__(self, page):
         """ Creates a new TagStore that uses pickle files.
-        
+
         @param page: a Page object where the tags should be related to
         """
 
@@ -416,7 +419,7 @@
             self.tags = []
         else:
             datafile.close()
-    
+
     def commit(self):
         """ Writes the memory contents to the data file. """
         datafile = file(self.filename, "wb")
@@ -468,3 +471,4 @@
 # currently we just have one implementation, so we do not need
 # a factory method
 TagStore = PickleTagStore
+
--- a/MoinMoin/xmlrpc/__init__.py	Sun Aug 20 16:59:51 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Sun Aug 20 17:00:17 2006 +0200
@@ -130,7 +130,7 @@
             else:
                 # wrap response in a singleton tuple
                 response = (response,)
-    
+
                 # serialize it
                 response = xmlrpclib.dumps(response, methodresponse=1)
 
@@ -182,7 +182,7 @@
         request.
 
         See http://www.xmlrpc.com/discuss/msgReader$1208
-        
+
         Copied from SimpleXMLRPCServer.py
         """
 
@@ -275,7 +275,7 @@
         pagelist = self.request.rootpage.getPageList(filter=p_filter, exists=not options["include_deleted"],
                                                      include_underlay=options["include_underlay"],
                                                      return_objects=options["include_revno"])
-        
+
         if options['include_revno']:
             pages = []
             for x in pagelist:
@@ -289,7 +289,7 @@
 
     def xmlrpc_getRecentChanges(self, date):
         """ Get RecentChanges since date
-        
+
         @param date: date since when rc will be listed
         @rtype: list
         @return: a list of changed pages since date, which should be in
@@ -695,14 +695,22 @@
     def xmlrpc_mergeDiff(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name, normalised_name):
         """ Merges a diff sent by the remote machine and returns the number of the new revision.
             Additionally, this method tags the new revision.
-            
+
             @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
@@ -712,7 +720,7 @@
         pagename = self._instr(pagename)
 
         comment = u"Remote Merge - %r" % unpackLine(interwiki_name)[-1]
-        
+
         # User may read page?
         if not self.request.user.may.read(pagename) or not self.request.user.may.write(pagename):
             return self.notAllowedFault()
@@ -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))
 
@@ -744,7 +759,7 @@
             return LASTREV_INVALID
 
         current_rev = currentpage.get_real_rev()
-        
+
         tags = TagStore(currentpage)
         tags.add(remote_wiki=interwiki_name, remote_rev=local_rev, current_rev=current_rev, direction=BOTH, normalised_name=normalised_name)
 
--- a/docs/CHANGES.aschremmer	Sun Aug 20 16:59:51 2006 +0200
+++ b/docs/CHANGES.aschremmer	Sun Aug 20 17:00:17 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,10 +15,8 @@
 
     * Test with prefixes
     * Search for XXX
-    * Delete iters?
     * Maybe refactor YYY into MoinLocalWiki
-    * Remove amount of "very" in the code
-    * Clean up trailing whitespace.
+    * Remove amount of "very" in the code, rename rp into sp
 
     * Implement a cross-site authentication system, i.e. mainly an
       identity storage. (does OpenID make sense?)