From b51a33f1ca3ee807ff538bd2e197ab9294da19d9 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 23 Jul 2012 14:39:56 +0200 Subject: [PATCH] Tag v0.2 --- CHANGES | 6 +++--- flask_weasyprint/__init__.py | 8 ++++---- flask_weasyprint/test_app.py | 7 ++++--- flask_weasyprint/tests.py | 5 ++++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 4905248..6894938 100644 --- a/CHANGES +++ b/CHANGES @@ -1,10 +1,10 @@ Version 0.2 ~~~~~~~~~~~ -Not released yet. +Released on 2012-07-23. -Add URL dispatcher and make Flask-WeasyPrint do the right thing with -apps that use subdomains. +Add URL dispatchers and make Flask-WeasyPrint do the right thing with +apps that use subdomains (when the ``SERVER_NAME`` config is set). Version 0.1 diff --git a/flask_weasyprint/__init__.py b/flask_weasyprint/__init__.py index 2a39184..1395422 100644 --- a/flask_weasyprint/__init__.py +++ b/flask_weasyprint/__init__.py @@ -18,7 +18,7 @@ from werkzeug.wrappers import Response -VERSION = '0.1' +VERSION = '0.2' __all__ = ['VERSION', 'make_flask_url_dispatcher', 'make_url_fetcher', 'HTML', 'CSS', 'render_pdf'] @@ -91,7 +91,7 @@ def make_url_fetcher(dispatcher=None, You generally don’t need to call this directly. If ``dispatcher`` is not provided, :func:`make_flask_url_dispatcher` - is called to get on. This requires a request context. + is called to get one. This requires a request context. Otherwise, it must be a callable that take an URL and return either ``None`` or a ``(wsgi_callable, base_url, path)`` tuple. For None @@ -184,8 +184,8 @@ def render_pdf(html, stylesheets=None, download_filename=None): :meth:`~weasyprint.HTML.write_pdf` :param download_filename: If provided, the ``Content-Disposition`` header is set so that most - web browser will show the "Save as…" dialog with the value a default - filename. + web browser will show the "Save as…" dialog with the value as the + default filename. :returns: a :class:`flask.Response` object. """ diff --git a/flask_weasyprint/test_app.py b/flask_weasyprint/test_app.py index a5524d6..762ad2e 100644 --- a/flask_weasyprint/test_app.py +++ b/flask_weasyprint/test_app.py @@ -47,13 +47,14 @@ def index(): @app.route('/foo/') def document_html(): - return render_template('document.html', - data=[42, 27.3, 63], labels=['Lorem', 'ipsum', 'sit']) + return render_template( + 'document.html', data=[42, 27.3, 63], labels=['Lorem', 'ipsum', 'sit']) @app.route('/foo/graph') def graph(): - svg = render_template('graph.svg', + svg = render_template( + 'graph.svg', # Turn ?data=3,2,1&labels=A,B,C into # [(0, ('A', 3, color0)), (1, ('B', 2, color1)), (2, ('C', 1, color2))] series=enumerate(zip( diff --git a/flask_weasyprint/tests.py b/flask_weasyprint/tests.py index 4826d12..95a590e 100644 --- a/flask_weasyprint/tests.py +++ b/flask_weasyprint/tests.py @@ -13,7 +13,6 @@ import io import struct import unittest -import urlparse import cairo from flask import Flask, redirect, request, json, jsonify @@ -85,6 +84,7 @@ def test_png(self): assert image.get_height() == 794 stride = image.get_stride() data = image.get_data() + def get_pixel(x, y): # cairo stores 32bit unsigned integers in *native* endianness uint32, = struct.unpack_from('=L', data, y * stride + x * 4) @@ -93,15 +93,18 @@ def get_pixel(x, y): rgb = uint32 & 0xffffff assert alpha == 0xff return '#%06X' % (rgb) + colors = [get_pixel(x, 320) for x in [180, 280, 380]] assert colors == app.config['GRAPH_COLORS'] assert data[:4] == b'\x00\x00\x00\x00' # Pixel (0, 0) is transparent def test_redirects(self): app = Flask(__name__) + def add_redirect(old_url, new_url): app.add_url_rule( old_url, 'redirect_' + old_url, lambda: redirect(new_url)) + add_redirect('/a', '/b') add_redirect('/b', '/c') add_redirect('/c', '/d')