changeset 764:3a042c4b99ee

merged
author Michael Mayorov <marchael@kb.csu.ru>
date Sun, 21 Aug 2011 23:58:28 +0000
parents f06e9d502d6c (current diff) 3e4ddf215182 (diff)
children 6c07d901c6b4
files
diffstat 6 files changed, 20 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/default.py	Sun Aug 21 23:31:52 2011 +0000
+++ b/MoinMoin/config/default.py	Sun Aug 21 23:58:28 2011 +0000
@@ -118,6 +118,9 @@
         if self.secrets is None:  # admin did not setup a real secret
             raise error.ConfigurationError("No secret configured! You need to set secrets = 'somelongsecretstring' in your wiki config.")
 
+        if self.interwikiname is None:  # admin did not setup a real interwikiname
+            raise error.ConfigurationError("No interwikiname configured! You need to set interwikiname = u'YourUniqueStableInterwikiName' in your wiki config.")
+
         secret_key_names = ['security/ticket', ]
         if self.textchas:
             secret_key_names.append('security/textcha')
@@ -321,7 +324,7 @@
   (
     ('sitename', u'Untitled Wiki',
      "Short description of your wiki site, displayed below the logo on each page, and used in RSS documents as the channel title [Unicode]"),
-    ('interwikiname', None, "unique and stable InterWiki name (prefix, moniker) of the site [Unicode], or None"),
+    ('interwikiname', None, "unique, stable and required InterWiki name (prefix, moniker) of the site [Unicode]"),
     ('html_pagetitle', None, "Allows you to set a specific HTML page title (if None, it defaults to the value of `sitename`) [Unicode]"),
     ('navi_bar', [
         ('wikilink', 'frontend.show_root', dict(), L_('Home'), L_('Home Page')),
--- a/MoinMoin/script/maint/index.py	Sun Aug 21 23:31:52 2011 +0000
+++ b/MoinMoin/script/maint/index.py	Sun Aug 21 23:58:28 2011 +0000
@@ -214,7 +214,7 @@
 
         backend = flaskg.unprotected_storage = app.unprotected_storage
         index_object = WhooshIndex(index_dir=app.cfg.index_dir_tmp)
-        interwikiname = app.cfg.interwikiname or u''
+        interwikiname = app.cfg.interwikiname
         if os.path.samefile(app.cfg.index_dir_tmp, app.cfg.index_dir):
             raise FatalError(u"cfg.index_dir and cfg.index_dir_tmp must point to different directories.")
 
--- a/MoinMoin/storage/backends/indexing.py	Sun Aug 21 23:31:52 2011 +0000
+++ b/MoinMoin/storage/backends/indexing.py	Sun Aug 21 23:58:28 2011 +0000
@@ -202,7 +202,7 @@
     Index for Items/Revisions
     """
     def __init__(self, cfg):
-        self.wikiname = cfg.interwikiname or u''
+        self.wikiname = cfg.interwikiname
         self.index_object = WhooshIndex(cfg=cfg)
 
     def close(self):
--- a/MoinMoin/user.py	Sun Aug 21 23:31:52 2011 +0000
+++ b/MoinMoin/user.py	Sun Aug 21 23:58:28 2011 +0000
@@ -454,8 +454,7 @@
         :param tm: timestamp
         """
         if self.valid:
-            interwikiname = self._cfg.interwikiname or u''
-            self.bookmarks[interwikiname] = int(tm)
+            self.bookmarks[self._cfg.interwikiname] = int(tm)
             self.save()
 
     def getBookmark(self):
@@ -465,10 +464,9 @@
         :returns: bookmark timestamp or None
         """
         bm = None
-        interwikiname = self._cfg.interwikiname or u''
         if self.valid:
             try:
-                bm = self.bookmarks[interwikiname]
+                bm = self.bookmarks[self._cfg.interwikiname]
             except (ValueError, KeyError):
                 pass
         return bm
@@ -479,10 +477,9 @@
         :rtype: int
         :returns: 0 on success, 1 on failure
         """
-        interwikiname = self._cfg.interwikiname or u''
         if self.valid:
             try:
-                del self.bookmarks[interwikiname]
+                del self.bookmarks[self._cfg.interwikiname]
             except KeyError:
                 return 1
             self.save()
@@ -518,9 +515,8 @@
 
         import re
         # Create a new list with both names and interwiki names.
-        pages = pagelist[:]
-        if self._cfg.interwikiname:
-            pages += [getInterwikiName(pagename) for pagename in pagelist]
+        pages = pagelist[:] # TODO: get rid of non-interwiki subscriptions?
+        pages += [getInterwikiName(pagename) for pagename in pagelist]
         # Create text for regular expression search
         text = '\n'.join(pages)
 
@@ -549,16 +545,12 @@
         :rtype: bool
         :returns: if page was subscribed
         """
-        if self._cfg.interwikiname:
-            pagename = getInterwikiName(pagename)
-
+        pagename = getInterwikiName(pagename)
         if pagename not in self.subscribed_items:
             self.subscribed_items.append(pagename)
             self.save()
-
             # XXX SubscribedToPageEvent
             return True
-
         return False
 
     def unsubscribe(self, pagename):
@@ -684,9 +676,7 @@
 
         :param item_name: the item name (unicode) to add to the trail
         """
-        # Save interwiki links internally
-        if self._cfg.interwikiname:
-            item_name = getInterwikiName(item_name)
+        item_name = getInterwikiName(item_name)
         trail_in_session = session.get('trail', [])
         trail = trail_in_session[:]
         trail = [i for i in trail if i != item_name] # avoid dupes
--- a/MoinMoin/util/interwiki.py	Sun Aug 21 23:31:52 2011 +0000
+++ b/MoinMoin/util/interwiki.py	Sun Aug 21 23:58:28 2011 +0000
@@ -122,7 +122,7 @@
         return wikiurl + wikitail
 
 
-def getInterwikiName(self, item_name):
+def getInterwikiName(item_name):
     """
     Get the (fully qualified) interwiki name of a local item name.
 
@@ -130,9 +130,7 @@
     :rtype: unicode
     :returns: wiki_name:item_name
     """
-    wiki_name = app.cfg.interwikiname
-    if wiki_name:
-        return "%s:%s" % (wiki_name, item_name)
+    return "%s:%s" % (app.cfg.interwikiname, item_name)
 
 
 def getInterwikiHome(username):
--- a/wikiconfig.py	Sun Aug 21 23:31:52 2011 +0000
+++ b/wikiconfig.py	Sun Aug 21 23:58:28 2011 +0000
@@ -12,7 +12,6 @@
     # vvv DON'T TOUCH THIS EXCEPT IF YOU KNOW WHAT YOU DO vvv
     # Directory containing THIS wikiconfig:
     wikiconfig_dir = os.path.abspath(os.path.dirname(__file__))
-    interwikiname = u'MoinMoin2'
     # We assume this structure for a simple "unpack and run" scenario:
     # wikiconfig.py
     # wiki/
@@ -46,15 +45,16 @@
                                              after=u'', ),
                             )
 
+    sitename = u'My MoinMoin'
+
+    # it is required that you set this to a unique, stable and non-empty name:
+    interwikiname = u'MyMoinMoin'
     # Load the interwiki map from intermap.txt:
     interwiki_map = InterWikiMap.from_file(os.path.join(wikiconfig_dir, 'contrib', 'interwiki', 'intermap.txt')).iwmap
     # we must add entries for 'Self' and our interwikiname:
-    #interwikiname = 'MyInterWikiName'
-    #interwiki_map[interwikiname] = 'http://localhost:8080/'
+    interwiki_map[interwikiname] = 'http://localhost:8080/'
     interwiki_map['Self'] = 'http://localhost:8080/'
 
-    sitename = u'My MoinMoin'
-
     # for now we load some 3rd party stuff from the place within moin where it is currently located,
     # but soon we'll get rid of this stuff:
     env_dir = 'env'