changeset 4636:83483f4e26cb

merged moin/1.8
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 07 Mar 2009 22:38:00 +0100
parents 554e1d780e3b (current diff) 716dcfb00e8e (diff)
children ff5be6bb7a49
files MoinMoin/action/AttachFile.py MoinMoin/action/login.py MoinMoin/script/migration/_conv160a_wiki.py
diffstat 8 files changed, 124 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Sat Mar 07 19:42:10 2009 +0100
+++ b/MoinMoin/action/AttachFile.py	Sat Mar 07 22:38:00 2009 +0100
@@ -1112,7 +1112,7 @@
                 fmt.url(0))
         request.write('For using an external program follow this link %s' % link)
         return
-    request.write(m.execute('EmbedObject', u'target=%s, pagename=%s' % (filename, pagename)))
+    request.write(m.execute('EmbedObject', u'target="%s", pagename="%s"' % (filename, pagename)))
     return
 
 
--- a/MoinMoin/action/login.py	Sat Mar 07 19:42:10 2009 +0100
+++ b/MoinMoin/action/login.py	Sat Mar 07 22:38:00 2009 +0100
@@ -63,13 +63,9 @@
         if islogin: # user pressed login button
             if request._login_multistage:
                 return self.handle_multistage()
-            error = []
             if hasattr(request, '_login_messages'):
                 for msg in request._login_messages:
-                    error.append('<p>')
-                    error.append(msg)
-                error = ''.join(error)
-            request.theme.add_msg(error, "error")
+                    request.theme.add_msg(msg, "error")
             return self.page.send_page()
 
         else: # show login form
--- a/MoinMoin/action/unsubscribe.py	Sat Mar 07 19:42:10 2009 +0100
+++ b/MoinMoin/action/unsubscribe.py	Sat Mar 07 22:38:00 2009 +0100
@@ -16,19 +16,16 @@
         request.theme.add_msg(_("You must login to use this action: %(action)s.") % {"action": actname}, "error")
         return Page(request, pagename).send_page()
 
-    msg = None
-
     if request.user.isSubscribedTo([pagename]):
         # Try to unsubscribe
         if request.user.unsubscribe(pagename):
-            msg = _('Your subscription to this page has been removed.')
+            request.theme.add_msg(_('Your subscription to this page has been removed.'), "info")
         else:
             msg = _("Can't remove regular expression subscription!") + u' ' + \
                   _("Edit the subscription regular expressions in your settings.")
+            request.theme.add_msg(msg, "error")
     else:
         # The user is not subscribed
-        msg = _('You need to be subscribed to unsubscribe.')
-    if msg:
-        request.theme.add_msg(msg)
+        request.theme.add_msg(_('You need to be subscribed to unsubscribe.'), "info")
     Page(request, pagename).send_page()
 
--- a/MoinMoin/auth/ldap_login.py	Sat Mar 07 19:42:10 2009 +0100
+++ b/MoinMoin/auth/ldap_login.py	Sat Mar 07 22:38:00 2009 +0100
@@ -72,6 +72,7 @@
         aliasname_attribute=None, # ('displayName') ldap attribute we get the aliasname from
         email_attribute=None, # ('mail') ldap attribute we get the email address from
         email_callback=None, # called to make up email address
+        name_callback=None, # called to use a Wiki name different from the login name
         coding='utf-8', # coding used for ldap queries and result values
         timeout=10, # how long we wait for the ldap server [s]
         start_tls=0, # 0 = No, 1 = Try, 2 = Required
@@ -96,6 +97,7 @@
         self.aliasname_attribute = aliasname_attribute
         self.email_attribute = email_attribute
         self.email_callback = email_callback
+        self.name_callback = name_callback
 
         self.coding = coding
         self.timeout = timeout
@@ -218,6 +220,9 @@
                         aliasname = sn
                 aliasname = aliasname.decode(coding)
 
+                if self.name_callback:
+                    username = self.name_callback(ldap_dict)
+
                 if email:
                     u = user.User(request, auth_username=username, auth_method=self.name, auth_attribs=('name', 'password', 'email', 'mailto_author', ))
                     u.email = email
--- a/MoinMoin/script/migration/_conv160a_wiki.py	Sat Mar 07 19:42:10 2009 +0100
+++ b/MoinMoin/script/migration/_conv160a_wiki.py	Sat Mar 07 22:38:00 2009 +0100
@@ -414,16 +414,16 @@
             else:
                 return '[[%s|%s]]' % (target, text)
 
+    def _parser_repl(self, word):
+        self.in_pre = 'no_parser'
+        return word
+
     def _pre_repl(self, word):
         w = word.strip()
         if w == '{{{' and not self.in_pre:
-            self.in_pre = True
+            self.in_pre = 'no_parser'
         elif w == '}}}' and self.in_pre:
-            self.in_pre = False
-        return word
-
-    def _processor_repl(self, word):
-        self.in_pre = True
+            self.in_pre = None
         return word
 
     def scan(self, scan_re, line):
--- a/MoinMoin/script/migration/_tests/test_conv160_wiki.py	Sat Mar 07 19:42:10 2009 +0100
+++ b/MoinMoin/script/migration/_tests/test_conv160_wiki.py	Sat Mar 07 22:38:00 2009 +0100
@@ -158,4 +158,42 @@
         for data, renames, expected in tests:
             assert convert_wiki(request, pagename, data, renames) == expected
 
+    def test_parser(self):
+        #py.test.skip("not wanted right now")
+        markup_15 = u"""\
+{{{#!html
+...
+}}}
 
+"""
+        expected_markup_160 = u"""\
+{{{#!html
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_15, {})
+        #print markup_15 ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+
+
+    def test_pre(self):
+        #py.test.skip("not wanted right now")
+        markup_15 = u"""\
+{{{
+...
+}}}
+
+"""
+        expected_markup_160 = u"""\
+{{{
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_15, {})
+        #print markup_15 ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+
--- a/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Sat Mar 07 19:42:10 2009 +0100
+++ b/MoinMoin/script/migration/_tests/test_conv160a_wiki.py	Sat Mar 07 22:38:00 2009 +0100
@@ -421,3 +421,39 @@
         markup_160 = markup_160.replace('\r\n', '\n')
         assert markup_160 == expected_markup_160
 
+    def test_parser(self):
+        markup_160a = u"""\
+{{{#!html
+...
+}}}
+
+"""
+        expected_markup_160 = u"""\
+{{{#!html
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_160a, {})
+        #print markup_160a ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+
+    def test_pre(self):
+        markup_160a = u"""\
+{{{
+...
+}}}
+
+"""
+        expected_markup_160 = u"""\
+{{{
+...
+}}}
+
+"""
+        markup_160 = convert_wiki(self.request, u'TestPage', markup_160a, {})
+        #print markup_160a ; print "---" ; print markup_160
+        markup_160 = markup_160.replace('\r\n', '\n')
+        assert markup_160 == expected_markup_160
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/theme/modernized_cms.py	Sat Mar 07 22:38:00 2009 +0100
@@ -0,0 +1,34 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - modernized_cms theme
+
+    @copyright: 2009 MoinMoin:ThomasWaldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.theme.modernized import Theme as ThemeBase
+
+class Theme(ThemeBase):
+
+    name = "modernized" # we tell that we are 'modernized', so we use its static data
+
+    def onlyloggedin(method):
+        """ decorator that returns empty string for not logged-in users,
+            otherwise it calls the decorated method
+        """
+        return lambda self, *args, **kwargs: (
+            self.request.user.valid and self.request.user.name and method(self, *args, **kwargs)
+            or
+            ''
+            )
+
+    interwiki = onlyloggedin(ThemeBase.interwiki)
+    title = onlyloggedin(ThemeBase.title)
+    username = onlyloggedin(ThemeBase.username)
+    pageinfo = onlyloggedin(ThemeBase.pageinfo)
+    editbar = onlyloggedin(ThemeBase.editbar)
+
+
+def execute(request):
+    return Theme(request)
+