changeset 4157:264e5687ef1c

Factoring out more parts of request.run
author Florian Krupicka <florian.krupicka@googlemail.com>
date Tue, 10 Jun 2008 21:28:39 +0200
parents 40501b3e2176
children 74e295d4a75e
files MoinMoin/web/utils.py
diffstat 1 files changed, 34 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/web/utils.py	Tue Jun 10 20:56:46 2008 +0200
+++ b/MoinMoin/web/utils.py	Tue Jun 10 21:28:39 2008 +0200
@@ -6,7 +6,12 @@
                 2008-2008 MoinMoin:FlorianKrupicka
     @license: GNU GPL, see COPYING for details.
 """
+from werkzeug.utils import redirect
+
 from MoinMoin import log
+from MoinMoin import wikiutil
+from MoinMoin.Page import Page
+
 logging = log.getLogger(__name__)
 
 def check_spider(useragent, cfg):
@@ -20,6 +25,33 @@
         is_spider = cfg.cache.ua_spiders.search(useragent.browser) is not None
     return is_spider
 
-def handle_auth_form(user_obj):
-    logging.warning("handle_auth_form needs to be implemented yet.")
+def handle_auth(user_obj, **kw):
+    logging.warning("handle_auth still needs implementation")
     return user_obj
+
+def handle_auth_form(user_obj, form):
+    username = form.get('name')
+    password = form.get('password')
+    openid_identifier = form.get('openid_identifier')
+    login = 'login' in form
+    logout = 'logout' in form
+    stage = form.get('stage')
+    attended = True
+    return handle_auth(user_obj, **locals())
+
+def redirect_last_visited(request):
+    pagetrail = request.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(request, wikiname, pagename)
+            url = wikiurl + wikiutil.quoteWikinameURL(wikitail)
+        else:
+            url = Page(request, pagename).url(request)
+    else:
+        # Or to localized FrontPage
+        url = wikiutil.getFrontPage(request).url(request)
+    url = request.getQualifiedURL(url)
+    return redirect(url)