diff MoinMoin/action/SyncPages.py @ 1386:0559fa036536

Added authentication support, fixed a few messages (added pagename).
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sun, 20 Aug 2006 23:46:06 +0200
parents 8bf6e48c6236
children fd3ceaad98d1
line wrap: on
line diff
--- a/MoinMoin/action/SyncPages.py	Sun Aug 20 18:37:26 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Sun Aug 20 23:46:06 2006 +0200
@@ -76,6 +76,8 @@
             "pageList": None,
             "groupList": None,
             "direction": "foo", # is defaulted below
+            "user": None,     # this should be refactored into a password agent
+            "password": None, # or OpenID like solution (XXX)
         }
 
         options.update(Dict(self.request, self.pagename).get_dict())
@@ -117,7 +119,6 @@
 
         params = self.fix_params(self.parse_page())
 
-        # XXX aquire readlock on self.page
         try:
             if params["direction"] == UP:
                 raise ActionStatus(_("The only supported directions are BOTH and DOWN."))
@@ -130,8 +131,8 @@
 
             local = MoinLocalWiki(self.request, params["localPrefix"], params["pageList"])
             try:
-                remote = MoinRemoteWiki(self.request, params["remoteWiki"], params["remotePrefix"], params["pageList"], verbose=debug)
-            except UnsupportedWikiException, (msg, ):
+                remote = MoinRemoteWiki(self.request, params["remoteWiki"], params["remotePrefix"], params["pageList"], params["user"], params["password"], verbose=debug)
+            except (UnsupportedWikiException, NotAllowedException), (msg, ):
                 raise ActionStatus(msg)
 
             if not remote.valid:
@@ -148,6 +149,7 @@
             else:
                 msg = u"%s" % (_("Syncronisation finished. Look below for the status messages."), )
         finally:
+            # XXX aquire readlock on self.page
             self.page.saveText(self.page.get_raw_body() + "\n\n" + self.generate_log_table(), 0)
             # XXX release readlock on self.page
 
@@ -312,7 +314,7 @@
                 return
 
             if remote_rev is None and direction == BOTH:
-                self.log_status(ActionClass.INFO, _("This is the first synchronisation between this page and the remote wiki."))
+                self.log_status(ActionClass.INFO, _("This is the first synchronisation between the local and the remote wiki for the page %s."), (sp.name, ))
 
             if sp.remote_deleted:
                 remote_contents = ""
@@ -362,7 +364,7 @@
                     try:
                         very_current_remote_rev = remote.merge_diff(sp.remote_name, compress(diff), new_local_rev, current_remote_rev, current_remote_rev, local_full_iwid, sp.name)
                     except NotAllowedException:
-                        self.log_status(ActionClass.ERROR, _("Page could not be merged because you are not allowed to modify the page in the remote wiki."))
+                        self.log_status(ActionClass.ERROR, _("The page %s could not be merged because you are not allowed to modify the page in the remote wiki."), (sp.name, ))
                         return
                 else:
                     very_current_remote_rev = current_remote_rev
@@ -375,9 +377,9 @@
             tags.add(remote_wiki=remote_full_iwid, remote_rev=very_current_remote_rev, current_rev=new_local_rev, direction=direction, normalised_name=sp.name)
 
             if sp.local_mime_type != MIMETYPE_MOIN or not wikiutil.containsConflictMarker(merged_text):
-                self.log_status(ActionClass.INFO, _("Page successfully merged."))
+                self.log_status(ActionClass.INFO, _("Page %s successfully merged."), (sp.name, ))
             else:
-                self.log_status(ActionClass.WARN, _("Page merged with conflicts."))
+                self.log_status(ActionClass.WARN, _("Page %s merged with conflicts."), (sp.name, ))
 
             # XXX release lock