Skip to content
Myr

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 · 11 files+49 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+49 added−11 removed

  • tests:+9 added−0 removed
  • other:+40 added−11 removed

11 files+49 added−11 removed

modified:docs/deploying/index.rst+1 added-1 removed
22 unmodified lines
23 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/>`_282829Self-hosted options30-------------------3132.. toctree::
7 unmodified lines
modified:docs/deploying/mod_wsgi.rst+6 added
191 unmodified lines
192193 activate_this = '/path/to/env/bin/activate_this.py'194 execfile(activate_this, dict(__file__=activate_this))195196For Python 3 add the following lines to the top of your ``.wsgi`` file::197198 activate_this = '/path/to/env/bin/activate_this.py'199 with open(activate_this) as file_:200 exec(file_.read(), dict(__file__=activate_this))201202This sets up the load paths according to the settings of the virtual203environment. Keep in mind that the path has to be absolute.
modified:docs/patterns/sqlalchemy.rst+1 added-1 removed
31 unmodified lines
32SQLAlchemy. It allows you to define tables and models in one go, similar33to how Django works. In addition to the following text I recommend the34official documentation on the `declarative`_ extension.3536Here the example :file:`database.py` module for your application::36Here's the example :file:`database.py` module for your application::3738 from sqlalchemy import create_engine39 from sqlalchemy.orm import scoped_session, sessionmaker40 from sqlalchemy.ext.declarative import declarative_base
178 unmodified lines
modified:docs/config.rst+2 added-1 removed
128 unmodified lines
129 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` or
325 unmodified lines
modified:flask/app.py+11 added-1 removed
244 unmodified lines
245 #: ``timedelta(days=31)``246 permanent_session_lifetime = ConfigAttribute('PERMANENT_SESSION_LIFETIME',247 get_converter=_make_timedelta)248249 #: 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)258259 #: 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 lines
306 '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 lines
modified:flask/helpers.py+13 added-1 removed
12 unmodified lines
13import sys14import pkgutil15import posixpath16import mimetypes17from datetime import timedelta18from time import time19from zlib import adler3220from threading import RLock21from werkzeug.routing import BuildError
834 unmodified lines
856 return flask.Flask.get_send_file_max_age(self, name)857858 .. versionadded:: 0.9859 """859 return current_app.config['SEND_FILE_MAX_AGE_DEFAULT']860 return total_seconds(current_app.send_file_max_age_default)861862 def send_static_file(self, filename):863 """Function used internally to send static files from the static864 folder to the browser.
33 unmodified lines
898 """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)902903904def total_seconds(td):905 """Returns the total seconds from a timedelta object.906907 :param timedelta td: the timedelta to be converted in seconds908909 :returns: number of seconds910 :rtype: int911 """912 return td.days * 60 * 60 * 24 + td.seconds
modified:flask/sessions.py+1 added-4 removed
15 unmodified lines
16from werkzeug.http import http_date, parse_date17from werkzeug.datastructures import CallbackDict18from . import Markup, json19from ._compat import iteritems, text_type20from .helpers import total_seconds2122from itsdangerous import URLSafeTimedSerializer, BadSignature232424def total_seconds(td):25 return td.days * 60 * 60 * 24 + td.seconds262725class SessionMixin(object):26 """Expands a basic dictionary with an accessors that are expected27 by Flask extensions and users for the session.28 """
334 unmodified lines
modified:tests/test_config.py+9 added
8 unmodified lines
910import pytest1112import os13from datetime import timedelta14import flask151617# config keys used for the TestConfig
150 unmodified lines
168 app.config['PERMANENT_SESSION_LIFETIME'] = 42169 assert app.permanent_session_lifetime.seconds == 42170171172def 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 == 7200178179180def 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 lines
modified:.travis.yml+3 added
5 unmodified lines
6 - "2.7"7 - "pypy"8 - "3.3"9 - "3.4"10 - "3.5"1112env:13 - REQUIREMENTS=lowest14 - REQUIREMENTS=release
5 unmodified lines
20 - python: "3.3"21 env: REQUIREMENTS=lowest22 - python: "3.4"23 env: REQUIREMENTS=lowest24 - python: "3.5"25 env: REQUIREMENTS=lowest262728install:29 - pip install tox
17 unmodified lines
modified:CHANGES+1 added-1 removed
110 unmodified lines
111112Version 0.10113------------114115Released on June 13nd 2013, codename Limoncello.115Released on June 13th 2013, codename Limoncello.116117- 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 lines
modified:tox.ini+1 added-1 removed
1[tox]2envlist = {py26,py27,pypy}-{lowest,release,devel}, {py33,py34}-{release,devel}2envlist = {py26,py27,pypy}-{lowest,release,devel}, {py33,py34,py35}-{release,devel}34[testenv]5commands =6 py.test []
22 unmodified lines