Mercurial > moin > 1.9
changeset 4321:4476d5ca521c
Move imports of werkzeug solely into the MoinMoin.web package (to make bundled werkzeug really work)
author | Florian Krupicka <florian.krupicka@googlemail.com> |
---|---|
date | Mon, 18 Aug 2008 11:24:58 +0200 |
parents | 9f41f41891aa |
children | d832ee2a53d2 |
files | MoinMoin/action/RenderAsDocbook.py MoinMoin/conftest.py MoinMoin/session.py MoinMoin/web/exceptions.py MoinMoin/web/request.py MoinMoin/web/utils.py MoinMoin/wsgiapp.py |
diffstat | 7 files changed, 14 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/action/RenderAsDocbook.py Mon Aug 18 00:39:46 2008 +0200 +++ b/MoinMoin/action/RenderAsDocbook.py Mon Aug 18 11:24:58 2008 +0200 @@ -4,12 +4,10 @@ @copyright: 2005 MoinMoin:AlexanderSchremmer @license: GNU GPL, see COPYING for details. """ -from werkzeug.exceptions import abort -from werkzeug.utils import redirect from MoinMoin.Page import Page def execute(pagename, request): url = Page(request, pagename).url(request, {'action': 'show', 'mimetype': 'text/docbook'}) - return abort(redirect(url)) + return request.http_redirect(url)
--- a/MoinMoin/conftest.py Mon Aug 18 00:39:46 2008 +0200 +++ b/MoinMoin/conftest.py Mon Aug 18 11:24:58 2008 +0200 @@ -25,8 +25,6 @@ import py -from werkzeug.test import Client - rootdir = py.magic.autopath().dirpath() moindir = rootdir.join("..") @@ -37,7 +35,7 @@ sys.path.insert(0, str(moindir.join("tests"))) from MoinMoin.support.python_compatibility import set -from MoinMoin.web.request import TestRequest +from MoinMoin.web.request import TestRequest, Client from MoinMoin.wsgiapp import application, init coverage_modules = set()
--- a/MoinMoin/session.py Mon Aug 18 00:39:46 2008 +0200 +++ b/MoinMoin/session.py Mon Aug 18 11:24:58 2008 +0200 @@ -13,14 +13,13 @@ import Cookie -from werkzeug.utils import cookie_date - from MoinMoin import log logging = log.getLogger(__name__) from MoinMoin import caching from MoinMoin.user import User from MoinMoin.util import random_string +from MoinMoin.web.utils import cookie_date import time, random class SessionData(object):
--- a/MoinMoin/web/exceptions.py Mon Aug 18 00:39:46 2008 +0200 +++ b/MoinMoin/web/exceptions.py Mon Aug 18 11:24:58 2008 +0200 @@ -10,6 +10,8 @@ from werkzeug import exceptions +HTTPException = exceptions.HTTPException + class SurgeProtection(exceptions.ServiceUnavailable): """ A surge protection error in MoinMoin is based on the HTTP status `Service Unavailable`. This HTTP exception gives a short description
--- a/MoinMoin/web/request.py Mon Aug 18 00:39:46 2008 +0200 +++ b/MoinMoin/web/request.py Mon Aug 18 11:24:58 2008 +0200 @@ -13,7 +13,8 @@ from werkzeug.wrappers import Response as WerkzeugResponse from werkzeug.utils import EnvironHeaders, cached_property, Href from werkzeug.utils import create_environ, url_encode -from werkzeug.http import parse_cache_control_header +from werkzeug.http import parse_cache_control_header, HeaderSet +from werkzeug.test import Client from MoinMoin import config
--- a/MoinMoin/web/utils.py Mon Aug 18 00:39:46 2008 +0200 +++ b/MoinMoin/web/utils.py Mon Aug 18 11:24:58 2008 +0200 @@ -9,7 +9,7 @@ import time from werkzeug.exceptions import abort -from werkzeug.utils import redirect +from werkzeug.utils import redirect, cookie_date from werkzeug.wrappers import Response from MoinMoin import log
--- a/MoinMoin/wsgiapp.py Mon Aug 18 00:39:46 2008 +0200 +++ b/MoinMoin/wsgiapp.py Mon Aug 18 11:24:58 2008 +0200 @@ -6,13 +6,11 @@ 2008-2008 MoinMoin:FlorianKrupicka @license: GNU GPL, see COPYING for details. """ -from werkzeug.http import HeaderSet -from werkzeug.exceptions import HTTPException - from MoinMoin.web.contexts import AllContext, Context, XMLRPCContext -from MoinMoin.web.request import Request, MoinMoinFinish -from MoinMoin.web.utils import check_forbidden, check_surge_protect, fatal_response - +from MoinMoin.web.exceptions import HTTPException +from MoinMoin.web.request import Request, MoinMoinFinish, HeaderSet +from MoinMoin.web.utils import check_forbidden, check_surge_protect, fatal_response, \ + redirect_last_visited from MoinMoin.Page import Page from MoinMoin import auth, i18n, user, wikiutil, xmlrpc, error from MoinMoin.action import get_names, get_available_actions @@ -114,7 +112,7 @@ # Handle request. We have these options: # 1. jump to page where user left off if not pagename and context.user.remember_last_visit and action_name == 'show': - response = handle_last_visit(context) + response = redirect_last_visited(context) # 2. handle action else: response = handle_action(context, pagename, action_name) @@ -143,7 +141,7 @@ page = Page(context, pagename) if page.exists(): url = page.url(context) - return abort(redirect(url)) + return context.http_redirect(url) msg = None # Complain about unknown actions @@ -231,23 +229,6 @@ else: return context.lang -def handle_last_visit(request, context): - """ Redirect to last visited page (or frontpage) on missing pagename. """ - pagetrail = context.user.getTrail() - if pagetrail: - # Redirect to last page visited - last_visited = pagetrail[-1] - wikiname, pagename = wikiutil.split_interwiki(last_visited) - if wikiname != 'Self': - wikitag, wikiurl, wikitail, error = wikiutil.resolve_interwiki(context, wikiname, pagename) - url = wikiurl + wikiutil.quoteWikinameURL(wikitail) - else: - url = Page(context, pagename).url(context) - else: - # Or to localized FrontPage - url = wikiutil.getFrontPage(context).url(context) - return abort(redirect(url)) - def application(environ, start_response): try: request = Request(environ)