diff MoinMoin/wikiutil.py @ 1085:2bcb7bdf94a2

Implemented an editable InterWikiMap, updated my CHANGES file.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Fri, 28 Jul 2006 22:45:59 +0200
parents ba25ee4ea61d
children 55ebe3c0867c
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Fri Jul 28 17:10:43 2006 +0200
+++ b/MoinMoin/wikiutil.py	Fri Jul 28 22:45:59 2006 +0200
@@ -6,8 +6,13 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import os, re, urllib, cgi
-import codecs, types
+import cgi
+import codecs
+import os
+import re
+import time
+import types
+import urllib
 
 from MoinMoin import util, version, config
 from MoinMoin.util import pysupport, filesys, lock
@@ -497,8 +502,13 @@
 #############################################################################
 def load_wikimap(request):
     """ load interwiki map (once, and only on demand) """
+    from MoinMoin.Page import Page
+
     try:
         _interwiki_list = request.cfg._interwiki_list
+        now = int(time.time())
+        if request.cfg._interwiki_ts + (3*60) < now: # 3 minutes caching time
+            raise AttributeError # refresh cache
     except AttributeError:
         _interwiki_list = {}
         lines = []
@@ -507,7 +517,7 @@
         # precedence over the shared one, and is thus read AFTER
         # the shared one
         intermap_files = request.cfg.shared_intermap
-        if not isinstance(intermap_files, type([])):
+        if not isinstance(intermap_files, list):
             intermap_files = [intermap_files]
         intermap_files.append(os.path.join(request.cfg.data_dir, "intermap.txt"))
 
@@ -517,6 +527,9 @@
                 lines.extend(f.readlines())
                 f.close()
 
+        # add the contents of the InterWikiMap page
+        lines += Page(request, "InterWikiMap").get_raw_body().splitlines()
+
         for line in lines:
             if not line or line[0] == '#': continue
             try:
@@ -536,6 +549,7 @@
 
         # save for later
         request.cfg._interwiki_list = _interwiki_list
+        request.cfg._interwiki_ts = now
 
     return _interwiki_list