changeset 4334:7add275cf4de

Fixed: deprecated (and missing) getBaseURL() method
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sat, 04 Oct 2008 18:59:22 +0200
parents b52a579db72d
children 4e55366ea37a
files MoinMoin/action/rss_rc.py MoinMoin/action/sisterpages.py MoinMoin/auth/__init__.py MoinMoin/auth/openidrp.py MoinMoin/events/emailnotify.py MoinMoin/events/jabbernotify.py MoinMoin/events/notification.py MoinMoin/formatter/text_docbook.py MoinMoin/user.py MoinMoin/userprefs/oid.py MoinMoin/web/contexts.py
diffstat 11 files changed, 23 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/rss_rc.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/action/rss_rc.py	Sat Oct 04 18:59:22 2008 +0200
@@ -105,9 +105,7 @@
         request.headers.add('Etag', etag)
 
         # send the generated XML document
-        baseurl = request.getBaseURL()
-        if not baseurl.endswith('/'):
-            baseurl += '/'
+        baseurl = request.url_root
 
         logo = re.search(r'src="([^"]*)"', cfg.logo_string)
         if logo:
@@ -136,7 +134,7 @@
 
         # emit channel description
         handler.startNode('channel', {
-            (handler.xmlns['rdf'], 'about'): request.getBaseURL(),
+            (handler.xmlns['rdf'], 'about'): request.url_root,
             })
         handler.simpleNode('title', cfg.sitename)
         page = Page(request, pagename)
--- a/MoinMoin/action/sisterpages.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/action/sisterpages.py	Sat Oct 04 18:59:22 2008 +0200
@@ -51,9 +51,7 @@
         request.headers.add("Etag", etag)
 
         # send the generated XML document
-        baseurl = request.getBaseURL()
-        if not baseurl.endswith('/'):
-            baseurl += '/'
+        baseurl = request.url_root
 
         # Get list of user readable pages
         pages = request.rootpage.getPageList()
--- a/MoinMoin/auth/__init__.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/auth/__init__.py	Sat Oct 04 18:59:22 2008 +0200
@@ -160,9 +160,7 @@
     if request.page:
         return request.page.url(request, querystr=fields)
     else:
-        qstr = wikiutil.makeQueryString(fields)
-        return ''.join([request.getBaseURL(), '?', qstr])
-
+        return request.abs_href(**fields)
 
 class LoginReturn(object):
     """ LoginReturn - base class for auth method login() return value"""
--- a/MoinMoin/auth/openidrp.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/auth/openidrp.py	Sat Oct 04 18:59:22 2008 +0200
@@ -282,7 +282,7 @@
 
             return_to = get_multistage_continuation_url(request, self.name,
                                                         {'oidstage': '1'})
-            trust_root = request.getBaseURL()
+            trust_root = request.url_root
             if oidreq.shouldSendRedirect():
                 redirect_url = oidreq.redirectURL(trust_root, return_to)
                 return MultistageRedirectLogin(redirect_url)
--- a/MoinMoin/events/emailnotify.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/events/emailnotify.py	Sat Oct 04 18:59:22 2008 +0200
@@ -136,7 +136,7 @@
     for lang in subscribers:
         recipients.extend(subscribers[lang])
 
-    attachlink = request.getBaseURL() + getAttachUrl(event.pagename, event.filename, request)
+    attachlink = request.url_root + getAttachUrl(event.pagename, event.filename, request)
     pagelink = request.getQualifiedURL(page.url(request, {}))
 
     for lang in subscribers:
--- a/MoinMoin/events/jabbernotify.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/events/jabbernotify.py	Sat Oct 04 18:59:22 2008 +0200
@@ -75,7 +75,7 @@
     for lang in subscribers:
         recipients.extend(subscribers[lang])
 
-    attachlink = request.getBaseURL() + getAttachUrl(event.pagename, event.filename, request)
+    attachlink = request.url_root + getAttachUrl(event.pagename, event.filename, request)
     pagelink = request.getQualifiedURL(page.url(request, {}))
 
     for lang in subscribers.keys():
--- a/MoinMoin/events/notification.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/events/notification.py	Sat Oct 04 18:59:22 2008 +0200
@@ -78,7 +78,7 @@
         'The "%(pagename)s" page has been changed by %(editor)s:\n') % {
             'pagename': page.page_name,
             'editor': page.uid_override or user.getUserIdentification(request),
-            'sitename': page.cfg.sitename or request.getBaseURL(),
+            'sitename': page.cfg.sitename or request.url_root,
         }
 
         # append a diff (or append full page text if there is no diff)
@@ -98,7 +98,7 @@
             'The page "%(pagename)s" has been deleted by %(editor)s:\n\n') % {
                 'pagename': page.page_name,
                 'editor': page.uid_override or user.getUserIdentification(request),
-                'sitename': page.cfg.sitename or request.getBaseURL(),
+                'sitename': page.cfg.sitename or request.url_root,
         }
 
     elif msgtype == "page_renamed":
@@ -107,7 +107,7 @@
             'The page "%(pagename)s" has been renamed from "%(oldname)s" by %(editor)s:\n') % {
                 'editor': page.uid_override or user.getUserIdentification(request),
                 'pagename': page.page_name,
-                'sitename': page.cfg.sitename or request.getBaseURL(),
+                'sitename': page.cfg.sitename or request.url_root,
                 'oldname': kwargs['old_name']
         }
 
@@ -150,7 +150,7 @@
 
     data['subject'] = _("New attachment added to page %(pagename)s on %(sitename)s") % {
                 'pagename': page_name,
-                'sitename': request.cfg.sitename or request.getBaseURL(),
+                'sitename': request.cfg.sitename or request.url_root,
                 }
 
     data['text'] = _("Dear Wiki user,\n\n"
--- a/MoinMoin/formatter/text_docbook.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/formatter/text_docbook.py	Sat Oct 04 18:59:22 2008 +0200
@@ -457,7 +457,7 @@
             src = kw['src']
             if src.startswith("/"):
                 # convert to absolute path:
-                src = self.request.getBaseURL()+src
+                src = self.request.url_root + src
             image.setAttribute('fileref', src)
         if kw.has_key('width'):
             image.setAttribute('width', str(kw['width']))
--- a/MoinMoin/user.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/user.py	Sat Oct 04 18:59:22 2008 +0200
@@ -1028,7 +1028,7 @@
 """) % (
                         self.name,
                         tok,
-                        self._request.getBaseURL(),
+                        self._request.url_root,
                         url_quote_plus(self.name),
                         tok, )
 
--- a/MoinMoin/userprefs/oid.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/userprefs/oid.py	Sat Oct 04 18:59:22 2008 +0200
@@ -82,7 +82,7 @@
                                              'handler': 'oid',
                                              'oid.return': '1'})
             return_to = request.getQualifiedURL(request.page.url(request, qstr))
-            trust_root = request.getBaseURL()
+            trust_root = request.url_root
             if oidreq.shouldSendRedirect():
                 redirect_url = oidreq.redirectURL(trust_root, return_to)
                 request.http_redirect(redirect_url)
--- a/MoinMoin/web/contexts.py	Sat Sep 27 00:24:43 2008 +0200
+++ b/MoinMoin/web/contexts.py	Sat Oct 04 18:59:22 2008 +0200
@@ -8,7 +8,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import time, inspect, StringIO, sys
+import time, inspect, StringIO, sys, warnings
 
 from werkzeug.utils import Headers, http_date, create_environ, redirect
 from werkzeug.exceptions import Unauthorized, NotFound, abort
@@ -308,6 +308,14 @@
         self.request.response = file_wrapper(fileobj, bufsize)
         raise MoinMoinFinish('sent file')
 
+    # fully deprecated functions, with warnings
+    def getBaseURL(self):
+        warnings.warn(
+            "request.getBaseURL() is deprecated, please use the request's "
+            "url_root property or the abs_href object if urls should be generated.",
+            DeprecationWarning)
+        return self.request.url_root
+
 class AuxilaryMixin(object):
     """
     Mixin for diverse attributes and methods that aren't clearly assignable