Merge branch 'master' of https://github.com/mitsuhiko/flask
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Abhijeet Kasurde · committed by Abhijeet Kasurde · parents 15f267e, 41622c8 · Browse files · 12 files·+50 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diff stats
12 files+50 added−12 removed
- tests:+9 added−0 removed
- other:+41 added−12 removed
Provenance
- Commit
b51e368- Tree
f6741cf- Author
Abhijeet Kasurde <akasurde@redhat.com>- Committer
Abhijeet Kasurde <akasurde@redhat.com>- Parent 1
15f267e- Parent 2
41622c8
12 files changed+50 added−12 removed
modified:docs/deploying/index.rst+1 added-1 removed
22 unmodified lines23 with `Flask-specific notes <http://flask.pocoo.org/snippets/48/>`_24 - `Deploying Flask on Webfaction <http://flask.pocoo.org/snippets/65/>`_25 - `Deploying Flask on Google App Engine <https://github.com/kamalgill/flask-appengine-template>`_26 - `Sharing your Localhost Server with Localtunnel <http://flask.pocoo.org/snippets/89/>`_27+- `Deploying on Azure (IIS) <https://azure.microsoft.com/documentation/articles/web-sites-python-configure/>`_28 28-29 Self-hosted options30 -------------------31 32 .. toctree::7 unmodified linesmodified:docs/deploying/mod_wsgi.rst+6 added
191 unmodified lines192 193 activate_this = '/path/to/env/bin/activate_this.py'194 execfile(activate_this, dict(__file__=activate_this))195 196+For Python 3 add the following lines to the top of your ``.wsgi`` file::197+198+ activate_this = '/path/to/env/bin/activate_this.py'199+ with open(activate_this) as file_:200+ exec(file_.read(), dict(__file__=activate_this))201+202 This sets up the load paths according to the settings of the virtual203 environment. Keep in mind that the path has to be absolute.modified:docs/patterns/distribute.rst+1 added-1 removed
120 unmodified lines121 'SQLAlchemy>=0.6',122 'BrokenPackage>=0.7,<=1.0'123 ]124 125-As mentioned earlier that dependencies are pulled from PyPI. What if you125+As mentioned earlier, dependencies are pulled from PyPI. What if you126 want to depend on a package that cannot be found on PyPI and won't be127 because it is an internal package you don't want to share with anyone?128 Just still do as if there was a PyPI entry for it and provide a list of129 alternative locations where distribute should look for tarballs::32 unmodified linesmodified:docs/patterns/sqlalchemy.rst+1 added-1 removed
31 unmodified lines32 SQLAlchemy. It allows you to define tables and models in one go, similar33 to how Django works. In addition to the following text I recommend the34 official documentation on the `declarative`_ extension.35 36-Here the example :file:`database.py` module for your application::36+Here's the example :file:`database.py` module for your application::37 38 from sqlalchemy import create_engine39 from sqlalchemy.orm import scoped_session, sessionmaker40 from sqlalchemy.ext.declarative import declarative_base178 unmodified linesmodified:docs/config.rst+2 added-1 removed
128 unmodified lines129 returning a 413 status code.130 ``SEND_FILE_MAX_AGE_DEFAULT`` Default cache control max age to use with131 :meth:`~flask.Flask.send_static_file` (the132 default static file handler) and133- :func:`~flask.send_file`, in133+ :func:`~flask.send_file`, as134+ :class:`datetime.timedelta` or as seconds.135 seconds. Override this value on a per-file136 basis using the137 :meth:`~flask.Flask.get_send_file_max_age`138 hook on :class:`~flask.Flask` or325 unmodified linesmodified:flask/app.py+11 added-1 removed
244 unmodified lines245 #: ``timedelta(days=31)``246 permanent_session_lifetime = ConfigAttribute('PERMANENT_SESSION_LIFETIME',247 get_converter=_make_timedelta)248 249+ #: A :class:`~datetime.timedelta` which is used as default cache_timeout250+ #: for the :func:`send_file` functions. The default is 12 hours.251+ #:252+ #: This attribute can also be configured from the config with the253+ #: ``SEND_FILE_MAX_AGE_DEFAULT`` configuration key. This configuration254+ #: variable can also be set with an integer value used as seconds.255+ #: Defaults to ``timedelta(hours=12)``256+ send_file_max_age_default = ConfigAttribute('SEND_FILE_MAX_AGE_DEFAULT',257+ get_converter=_make_timedelta)258+259 #: Enable this if you want to use the X-Sendfile feature. Keep in260 #: mind that the server has to support this. This only affects files261 #: sent with the :func:`send_file` method.262 #:43 unmodified lines306 'SESSION_COOKIE_HTTPONLY': True,307 'SESSION_COOKIE_SECURE': False,308 'SESSION_REFRESH_EACH_REQUEST': True,309 'MAX_CONTENT_LENGTH': None,300- 'SEND_FILE_MAX_AGE_DEFAULT': 12 * 60 * 60, # 12 hours310+ 'SEND_FILE_MAX_AGE_DEFAULT': timedelta(hours=12),311 'TRAP_BAD_REQUEST_ERRORS': False,312 'TRAP_HTTP_EXCEPTIONS': False,313 'EXPLAIN_TEMPLATE_LOADING': False,314 'PREFERRED_URL_SCHEME': 'http',1671 unmodified linesmodified:flask/helpers.py+13 added-1 removed
12 unmodified lines13 import sys14 import pkgutil15 import posixpath16 import mimetypes17+from datetime import timedelta18 from time import time19 from zlib import adler3220 from threading import RLock21 from werkzeug.routing import BuildError834 unmodified lines856 return flask.Flask.get_send_file_max_age(self, name)857 858 .. versionadded:: 0.9859 """859- return current_app.config['SEND_FILE_MAX_AGE_DEFAULT']860+ return total_seconds(current_app.send_file_max_age_default)861 862 def send_static_file(self, filename):863 """Function used internally to send static files from the static864 folder to the browser.33 unmodified lines898 """899 if mode not in ('r', 'rb'):900 raise ValueError('Resources can only be opened for reading')901 return open(os.path.join(self.root_path, resource), mode)902+903+904+def total_seconds(td):905+ """Returns the total seconds from a timedelta object.906+907+ :param timedelta td: the timedelta to be converted in seconds908+909+ :returns: number of seconds910+ :rtype: int911+ """912+ return td.days * 60 * 60 * 24 + td.secondsmodified:flask/sessions.py+1 added-4 removed
15 unmodified lines16 from werkzeug.http import http_date, parse_date17 from werkzeug.datastructures import CallbackDict18 from . import Markup, json19 from ._compat import iteritems, text_type20+from .helpers import total_seconds21 22 from itsdangerous import URLSafeTimedSerializer, BadSignature23 24 24-def total_seconds(td):25- return td.days * 60 * 60 * 24 + td.seconds26-27-25 class SessionMixin(object):26 """Expands a basic dictionary with an accessors that are expected27 by Flask extensions and users for the session.28 """334 unmodified linesmodified:tests/test_config.py+9 added
8 unmodified lines9 10 import pytest11 12 import os13+from datetime import timedelta14 import flask15 16 17 # config keys used for the TestConfig150 unmodified lines168 app.config['PERMANENT_SESSION_LIFETIME'] = 42169 assert app.permanent_session_lifetime.seconds == 42170 171 172+def test_send_file_max_age():173+ app = flask.Flask(__name__)174+ app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 3600175+ assert app.send_file_max_age_default.seconds == 3600176+ app.config['SEND_FILE_MAX_AGE_DEFAULT'] = timedelta(hours=2)177+ assert app.send_file_max_age_default.seconds == 7200178+179+180 def test_get_namespace():181 app = flask.Flask(__name__)182 app.config['FOO_OPTION_1'] = 'foo option 1'183 app.config['FOO_OPTION_2'] = 'foo option 2'18 unmodified linesmodified:.travis.yml+3 added
5 unmodified lines6 - "2.7"7 - "pypy"8 - "3.3"9 - "3.4"10+ - "3.5"11 12 env:13 - REQUIREMENTS=lowest14 - REQUIREMENTS=release5 unmodified lines20 - python: "3.3"21 env: REQUIREMENTS=lowest22 - python: "3.4"23 env: REQUIREMENTS=lowest24+ - python: "3.5"25+ env: REQUIREMENTS=lowest26 27 28 install:29 - pip install tox17 unmodified linesmodified:CHANGES+1 added-1 removed
110 unmodified lines111 112 Version 0.10113 ------------114 115-Released on June 13nd 2013, codename Limoncello.115+Released on June 13th 2013, codename Limoncello.116 117 - Changed default cookie serialization format from pickle to JSON to118 limit the impact an attacker can do if the secret key leaks. See119 :ref:`upgrading-to-010` for more information.437 unmodified linesmodified:tox.ini+1 added-1 removed
1 [tox]2-envlist = {py26,py27,pypy}-{lowest,release,devel}, {py33,py34}-{release,devel}2+envlist = {py26,py27,pypy}-{lowest,release,devel}, {py33,py34,py35}-{release,devel}3 4 [testenv]5 commands =6 py.test []22 unmodified lines