changeset 1053:6632f9919a89

Implemented IWID system.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Tue, 25 Jul 2006 00:53:08 +0200
parents 018bb4266d57
children 59cc54eb48ab
files MoinMoin/action/SyncPages.py MoinMoin/config/multiconfig.py MoinMoin/xmlrpc/__init__.py
diffstat 3 files changed, 44 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/SyncPages.py	Tue Jul 25 00:46:41 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Tue Jul 25 00:53:08 2006 +0200
@@ -80,7 +80,7 @@
 
     # Methods implementing the RemoteWiki interface
     def getInterwikiName(self):
-        return self.connection.interwikiName()
+        return self.connection.interwikiName()[0]
 
     def getPages(self):
         pages = self.connection.getAllPagesEx({"include_revno": True, "include_deleted": True})
--- a/MoinMoin/config/multiconfig.py	Tue Jul 25 00:46:41 2006 +0200
+++ b/MoinMoin/config/multiconfig.py	Tue Jul 25 00:53:08 2006 +0200
@@ -7,8 +7,12 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import re, os, sys
-from MoinMoin import error
+import re
+import os
+import sys
+import time
+
+from MoinMoin import error, util
 import MoinMoin.auth as authmodule
 
 _url_re_cache = None
@@ -547,6 +551,37 @@
 
         # check if mail is possible and set flag:
         self.mail_enabled = (self.mail_smarthost is not None or self.mail_sendmail is not None) and self.mail_from
+        
+        # interwiki ID processing
+        self.load_IWID()
+
+    def load_IWID(self):
+        """ Loads the InterWikiID of this instance. It is used to identify the instance
+            globally.
+            The data file can be found in data/IWID
+            The IWID is available as cfg.iwid
+            The full IWID containing the interwiki name is available as cfg.iwid_full
+        """
+        iwid_path = os.path.join(self.data_dir, "IWID")
+
+        try:
+            iwid_file = file(iwid_path, "rb")
+            iwid = iwid_file.readline().strip()
+            iwid_file.close()
+        except IOError:
+            iwid = None
+
+        if iwid is None:
+            iwid = util.random_string(16).encode("hex") + "-" + str(int(time.time()))
+            iwid_file = file(iwid_path, "wb")
+            iwid_file.write(iwid)
+            iwid_file.close()
+
+        self.iwid = iwid
+        if self.interwikiname is not None:
+            self.iwid_full = iwid + ":" + self.interwikiname
+        else:
+            self.iwid_full = iwid
 
     def _config_check(self):
         """ Check namespace and warn about unknown names
--- a/MoinMoin/xmlrpc/__init__.py	Tue Jul 25 00:46:41 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Tue Jul 25 00:53:08 2006 +0200
@@ -20,7 +20,8 @@
     when really necessary (like for transferring binary files like
     attachments maybe).
 
-    @copyright: 2003-2005 by Thomas Waldmann
+    @copyright: 2003-2006 MoinMoin:ThomasWaldmann
+    @copyright: 2004-2006 MoinMoin:AlexanderSchremmer
     @license: GNU GPL, see COPYING for details
 """
 from MoinMoin.util import pysupport
@@ -608,12 +609,13 @@
         return {"conflict": conflict, "diff": diffblob, "diffversion": 1, "current": currentpage.get_real_rev()}
 
     def xmlrpc_interwikiName(self):
-        """ Returns the interwiki name of the current wiki. """
+        """ Returns the interwiki name and the IWID of the current wiki. """
         name = self.request.cfg.interwikiname
+        iwid = self.request.cfg.iwid
         if name is None:
-            return None
+            return [None, iwid]
         else:
-            return self._outstr(name)
+            return [self._outstr(name), iwid]
 
     def xmlrpc_mergeChanges(self, pagename, diff, local_rev, delta_remote_rev, last_remote_rev, interwiki_name):
         """ Merges a diff sent by the remote machine and returns the number of the new revision.