# HG changeset patch # User Daniele Nicolodi # Date 1308146140 -7200 # Node ID 9a835002fe4959b5be1848ec30a1f53b6e8b2490 # Parent ceb5df800c512199d286954ca7a0b852d0a960fa Fix URL generation bugs discovered in tesing on deployment server. diff -r ceb5df800c51 -r 9a835002fe49 src/ltpdarepo/__init__.py --- a/src/ltpdarepo/__init__.py Wed Jun 15 12:49:46 2011 +0200 +++ b/src/ltpdarepo/__init__.py Wed Jun 15 15:55:40 2011 +0200 @@ -1,4 +1,5 @@ -from flask import Flask, g, request, session, render_template, Markup, redirect, flash +from urlparse import urljoin +from flask import Flask, g, request, session, render_template, Markup, redirect, flash, url_for from pkg_resources import get_distribution import MySQLdb as mysql @@ -59,13 +60,13 @@ @app.template_filter('breadcrumbs') def breadcrumbs(path): - url = ['', ] + url = [] parts = [] for item in path.split('/')[1:-1]: url.append(item) if item: - parts.append((item, '/'.join(url))) - out = ['home', ] + parts.append((item, urljoin(url_for('.index'), '/'.join(url)))) + out = ['home' % url_for('.index'), ] for name, href in parts[1:]: out.append('%s' % (href, name)) if len(out) > 1: @@ -78,7 +79,7 @@ if request.method == 'POST': if authenticate(request.form['username'], request.form['password']): session['username'] = request.form['username'] - url = request.args.get('next', '/') + url = urljoin(url_for('.index'), request.args.get('next', '')) return redirect(url) flash('Login failed.', category='error') @@ -88,7 +89,7 @@ @app.route('/logout') def logout(): session.pop('username', None) - return redirect('/') + return redirect(url_for('.index')) @app.route('/') diff -r ceb5df800c51 -r 9a835002fe49 src/ltpdarepo/templates/layout.html --- a/src/ltpdarepo/templates/layout.html Wed Jun 15 12:49:46 2011 +0200 +++ b/src/ltpdarepo/templates/layout.html Wed Jun 15 15:55:40 2011 +0200 @@ -4,13 +4,13 @@ {% block title %} {% endblock %} — LTPDA Repository - + {%- block head %}{% endblock %}
-

LTPDA Repository

+

LTPDA Repository

{{ request.host }}
@@ -25,9 +25,9 @@ logout {% endif %} - +
 
- + {% for category, message in get_flashed_messages(True) %}
{{ message }}
{% endfor %} diff -r ceb5df800c51 -r 9a835002fe49 src/ltpdarepo/templates/query.html --- a/src/ltpdarepo/templates/query.html Wed Jun 15 12:49:46 2011 +0200 +++ b/src/ltpdarepo/templates/query.html Wed Jun 15 15:55:40 2011 +0200 @@ -1,8 +1,8 @@ {% extends "layout.html" %} {% block title %}{{ database.id }}{% endblock %} {% block head %} - - + +