changeset 1055:61142a50c41b

Merge with sync.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Tue, 25 Jul 2006 00:55:19 +0200
parents 3b5603bf468d (current diff) 59cc54eb48ab (diff)
children a2cb15c16cf4 91e8f75b006b 40b708ecc332
files
diffstat 6 files changed, 56 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Mon Jul 24 22:35:28 2006 +0200
+++ b/MoinMoin/Page.py	Tue Jul 25 00:55:19 2006 +0200
@@ -1389,7 +1389,11 @@
         import MoinMoin
         if hasattr(MoinMoin, '__loader__'):
             __file__ = os.path.join(MoinMoin.__loader__.archive, 'dummy')
-        exec code
+
+        try:
+            exec code
+        except "CacheNeedsUpdate": # convert the exception
+            raise Exception("CacheNeedsUpdate")
 
     def loadCache(self, request):
         """ Return page content cache or raises 'CacheNeedsUpdate' """
--- a/MoinMoin/action/SyncPages.py	Mon Jul 24 22:35:28 2006 +0200
+++ b/MoinMoin/action/SyncPages.py	Tue Jul 25 00:55:19 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	Mon Jul 24 22:35:28 2006 +0200
+++ b/MoinMoin/config/multiconfig.py	Tue Jul 25 00:55:19 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/util/__init__.py	Mon Jul 24 22:35:28 2006 +0200
+++ b/MoinMoin/util/__init__.py	Tue Jul 25 00:55:19 2006 +0200
@@ -7,7 +7,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import os, sys, re
+import os, sys, re, random
 
 #############################################################################
 ### XML helper functions
@@ -112,3 +112,7 @@
     def close(self):
         self.buffer = None
 
+
+def random_string(length):
+    chars = ''.join([chr(random.randint(0, 255)) for x in xrange(length)])
+    return chars
--- a/MoinMoin/xmlrpc/__init__.py	Mon Jul 24 22:35:28 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Tue Jul 25 00:55:19 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.
--- a/docs/CHANGES.aschremmer	Mon Jul 24 22:35:28 2006 +0200
+++ b/docs/CHANGES.aschremmer	Tue Jul 25 00:55:19 2006 +0200
@@ -26,6 +26,7 @@
     * TagStore/PickleTagStore class
     * XMLRPC method to get the pagelist in a special way (revnos,
       no system pages etc.)
+    * IWID support - i.e. every instance has a unique ID
 
   Bugfixes (only stuff that is buggy in moin/1.6 main branch):
     * Conflict resolution fixes. (merged into main)
@@ -67,6 +68,7 @@
          script written by Stefan Merten.
 Week 29: Finished first version of the mergeChanges method. Added Tag and TagStore classes which are currently
          using pickle-based storage. Added getAllPagesEx XMLRPC method.
+Week 30: Implemented IWID support, added function to generate random strings.
 
 2006-07-18: the requested daily entry is missing here, see http://moinmoin.wikiwikiweb.de/GoogleSoc2006/BetterProgress
 2006-07-19: the requested daily entry is missing here, see http://moinmoin.wikiwikiweb.de/GoogleSoc2006/BetterProgress