Mercurial > public > src > moin > 1.9
diff MoinMoin/config/multiconfig.py @ 1053:6632f9919a89
Implemented IWID system.
author | Alexander Schremmer <alex AT alexanderweb DOT de> |
---|---|
date | Tue, 25 Jul 2006 00:53:08 +0200 |
parents | 58f5af49cd03 |
children | f8ba3b0ca9f4 |
line wrap: on
line diff
--- 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