changeset 4579:87d97510de79

getScriptname() -> script_root, getBaseURL() -> url_root (for werkzeug API)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 15 Feb 2009 01:37:51 +0100
parents ace3bbadf66d
children 606234778ffc
files MoinMoin/PageGraphicalEditor.py MoinMoin/action/backup.py MoinMoin/action/fckdialog.py MoinMoin/action/sisterpages.py MoinMoin/action/sitemap.py MoinMoin/script/migration/wikiutil160a.py MoinMoin/user.py MoinMoin/userprefs/oidserv.py MoinMoin/web/contexts.py
diffstat 9 files changed, 24 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageGraphicalEditor.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/PageGraphicalEditor.py	Sun Feb 15 01:37:51 2009 +0100
@@ -313,9 +313,7 @@
         url_prefix_local = request.cfg.url_prefix_local
         wikipage = wikiutil.quoteWikinameURL(self.page_name)
         fckbasepath = url_prefix_local + '/applets/FCKeditor'
-        wikiurl = request.script_root
-        if not wikiurl or wikiurl[-1] != '/':
-            wikiurl += '/'
+        wikiurl = request.script_root + '/'
         themepath = '%s/%s' % (url_prefix_static, request.theme.name)
         smileypath = themepath + '/img'
         # auto-generating a list for SmileyImages does NOT work from here!
--- a/MoinMoin/action/backup.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/action/backup.py	Sun Feb 15 01:37:51 2009 +0100
@@ -71,7 +71,7 @@
 <input type="submit" value="%(backup_button)s">
 </form>
 """ % {
-    'baseurl': request.url_root,
+    'baseurl': request.script_root,
     'pagename': wikiutil.quoteWikinameURL(pagename),
     'backup_button': _('Backup'),
 })
--- a/MoinMoin/action/fckdialog.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/action/fckdialog.py	Sun Feb 15 01:37:51 2009 +0100
@@ -239,9 +239,7 @@
 
     # wiki url
     url_prefix_static = request.cfg.url_prefix_static
-    scriptname = request.script_root
-    if not scriptname or scriptname[-1] != "/":
-        scriptname += "/"
+    scriptname = request.script_root + '/'
     action = scriptname
     basepage = request.page.page_name
     request.write(u'''
@@ -389,9 +387,7 @@
 
     # wiki url
     url_prefix_static = request.cfg.url_prefix_static
-    scriptname = request.script_root
-    if not scriptname or scriptname[-1] != "/":
-        scriptname += "/"
+    scriptname = request.script_root + '/'
     action = scriptname
     request.write('''
 <!--
--- a/MoinMoin/action/sisterpages.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/action/sisterpages.py	Sun Feb 15 01:37:51 2009 +0100
@@ -51,8 +51,6 @@
         request.headers.add("Etag", etag)
 
         # send the generated XML document
-        baseurl = request.url_root
-
         # Get list of user readable pages
         pages = request.rootpage.getPageList()
         pages.sort()
--- a/MoinMoin/action/sitemap.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/action/sitemap.py	Sun Feb 15 01:37:51 2009 +0100
@@ -64,7 +64,7 @@
     _ = request.getText
     request.user.datetime_fmt = datetime_fmt
 
-    request.mimetype ='text/xml'
+    request.mimetype = 'text/xml'
 
     # we emit a piece of data so other side doesn't get bored:
     request.write("""<?xml version="1.0" encoding="UTF-8"?>\r\n""")
@@ -73,9 +73,7 @@
     result.append("""<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">\n""")
 
     # we include the root url as an important and often changed URL
-    rooturl = request.url_root
-    if not rooturl.endswith('/'):
-        rooturl += '/'
+    rooturl = request.script_root + '/'
     result.append(make_url_xml(request, {
         'url': rooturl,
         'lastmod': now(), # fake
--- a/MoinMoin/script/migration/wikiutil160a.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/script/migration/wikiutil160a.py	Sun Feb 15 01:37:51 2009 +0100
@@ -544,7 +544,7 @@
         for line in lines:
             if not line or line[0] == '#': continue
             try:
-                line = "%s %s/InterWiki" % (line, request.url_root)
+                line = "%s %s/InterWiki" % (line, request.script_root)
                 wikitag, urlprefix, dummy = line.split(None, 2)
             except ValueError:
                 pass
@@ -554,9 +554,9 @@
         del lines
 
         # add own wiki as "Self" and by its configured name
-        _interwiki_list['Self'] = request.url_root + '/'
+        _interwiki_list['Self'] = request.script_root + '/'
         if request.cfg.interwikiname:
-            _interwiki_list[request.cfg.interwikiname] = request.url_root + '/'
+            _interwiki_list[request.cfg.interwikiname] = request.script_root + '/'
 
         # save for later
         request.cfg.cache.interwiki_list = _interwiki_list
@@ -615,7 +615,7 @@
     if _interwiki_list.has_key(wikiname):
         return (wikiname, _interwiki_list[wikiname], pagename, False)
     else:
-        return (wikiname, request.url_root, "/InterWiki", True)
+        return (wikiname, request.script_root, "/InterWiki", True)
 
 def join_wiki(wikiurl, wikitail):
     """
@@ -1522,7 +1522,7 @@
     if text is None:
         text = params # default
     if formatter:
-        url = "%s/%s" % (request.url_root, params)
+        url = "%s/%s" % (request.script_root, params)
         # formatter.url will escape the url part
         if on is not None:
             tag = formatter.url(on, url, css_class, **kw)
@@ -1541,7 +1541,7 @@
                 attrs += ' id="%s"' % id
             if name:
                 attrs += ' name="%s"' % name
-            tag = '<a%s href="%s/%s">' % (attrs, request.url_root, params)
+            tag = '<a%s href="%s/%s">' % (attrs, request.script_root, params)
             if not on:
                 tag = "%s%s</a>" % (tag, text)
         request.log("Warning: wikiutil.link_tag called without formatter and without request.html_formatter. tag=%r" % (tag, ))
--- a/MoinMoin/user.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/user.py	Sun Feb 15 01:37:51 2009 +0100
@@ -1030,7 +1030,7 @@
 """) % (
                         self.name,
                         tok,
-                        self._request.url_root,
+                        self._request.script_root,
                         url_quote_plus(self.name),
                         tok, )
 
--- a/MoinMoin/userprefs/oidserv.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/userprefs/oidserv.py	Sun Feb 15 01:37:51 2009 +0100
@@ -61,7 +61,7 @@
             return self._handle_remove()
 
     def _make_form(self):
-        sn = self.request.url_root
+        sn = self.request.script_root
         pi = self.request.getPathinfo()
         action = u"%s%s" % (sn, pi)
         _form = html.FORM(action=action)
--- a/MoinMoin/web/contexts.py	Sat Feb 14 23:47:37 2009 +0100
+++ b/MoinMoin/web/contexts.py	Sun Feb 15 01:37:51 2009 +0100
@@ -309,6 +309,12 @@
         raise MoinMoinFinish('sent file')
 
     # fully deprecated functions, with warnings
+    def getScriptname(self):
+        warnings.warn(
+            "request.getScriptname() is deprecated, please use the request's script_root property.",
+            DeprecationWarning)
+        return self.request.script_root
+
     def getBaseURL(self):
         warnings.warn(
             "request.getBaseURL() is deprecated, please use the request's "
@@ -329,12 +335,13 @@
         if scheme:
             return uri
 
-        result = "%s%s" % (self.request.host_url, uri)
+        host_url = self.request.host_url.rstrip('/')
+        result = "%s%s" % (host_url, uri)
 
         # This might break qualified urls in redirects!
         # e.g. mapping 'http://netloc' -> '/'
-        return wikiutil.mapURL(self, result)
-
+        result = wikiutil.mapURL(self, result)
+        return result
 
 class AuxilaryMixin(object):
     """