forked from orbit-oss/flask
Added missing comments, fixed setup.py and made tests pass
This commit is contained in:
parent
dd59d7241d
commit
4f8ee8f129
10 changed files with 103 additions and 12 deletions
|
|
@ -16,6 +16,7 @@ from werkzeug import abort, redirect
|
||||||
from jinja2 import Markup, escape
|
from jinja2 import Markup, escape
|
||||||
|
|
||||||
from flask.app import Flask
|
from flask.app import Flask
|
||||||
|
from flask.config import Config
|
||||||
from flask.helpers import url_for, jsonify, json_available, flash, send_file, \
|
from flask.helpers import url_for, jsonify, json_available, flash, send_file, \
|
||||||
get_flashed_messages, render_template, render_template, render_template_string, \
|
get_flashed_messages, render_template, render_template, render_template_string, \
|
||||||
get_template_attribute, json
|
get_template_attribute, json
|
||||||
|
|
|
||||||
13
flask/app.py
13
flask/app.py
|
|
@ -1,3 +1,14 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.app
|
||||||
|
~~~~~~~~~
|
||||||
|
|
||||||
|
This module implements the central WSGI application object.
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
@ -10,7 +21,7 @@ from werkzeug.exceptions import HTTPException, InternalServerError
|
||||||
from flask.helpers import _PackageBoundObject, url_for, get_flashed_messages, \
|
from flask.helpers import _PackageBoundObject, url_for, get_flashed_messages, \
|
||||||
_tojson_filter, get_pkg_resources
|
_tojson_filter, get_pkg_resources
|
||||||
from flask.wrappers import Request, Response
|
from flask.wrappers import Request, Response
|
||||||
from flask.conf import ConfigAttribute, Config
|
from flask.config import ConfigAttribute, Config
|
||||||
from flask.ctx import _default_template_ctx_processor, _RequestContext
|
from flask.ctx import _default_template_ctx_processor, _RequestContext
|
||||||
from flask.globals import _request_ctx_stack, request
|
from flask.globals import _request_ctx_stack, request
|
||||||
from flask.session import Session, _NullSession
|
from flask.session import Session, _NullSession
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.config
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Implements the configuration related objects.
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
16
flask/ctx.py
16
flask/ctx.py
|
|
@ -1,10 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.ctx
|
||||||
|
~~~~~~~~~
|
||||||
|
|
||||||
|
Implements the objects required to keep the context.
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
from werkzeug.exceptions import HTTPException
|
from werkzeug.exceptions import HTTPException
|
||||||
|
|
||||||
from flask.wrappers import _RequestGlobals
|
|
||||||
from flask.globals import _request_ctx_stack
|
from flask.globals import _request_ctx_stack
|
||||||
from flask.session import _NullSession
|
from flask.session import _NullSession
|
||||||
|
|
||||||
|
|
||||||
|
class _RequestGlobals(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class _RequestContext(object):
|
class _RequestContext(object):
|
||||||
"""The request context contains all request relevant information. It is
|
"""The request context contains all request relevant information. It is
|
||||||
created at the beginning of the request and pushed to the
|
created at the beginning of the request and pushed to the
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.globals
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Defines all the global objects that are proxies to the current
|
||||||
|
active context.
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
from werkzeug import LocalStack, LocalProxy
|
from werkzeug import LocalStack, LocalProxy
|
||||||
|
|
||||||
# context locals
|
# context locals
|
||||||
|
|
@ -5,4 +17,4 @@ _request_ctx_stack = LocalStack()
|
||||||
current_app = LocalProxy(lambda: _request_ctx_stack.top.app)
|
current_app = LocalProxy(lambda: _request_ctx_stack.top.app)
|
||||||
request = LocalProxy(lambda: _request_ctx_stack.top.request)
|
request = LocalProxy(lambda: _request_ctx_stack.top.request)
|
||||||
session = LocalProxy(lambda: _request_ctx_stack.top.session)
|
session = LocalProxy(lambda: _request_ctx_stack.top.session)
|
||||||
g = LocalProxy(lambda: _request_ctx_stack.top.g)
|
g = LocalProxy(lambda: _request_ctx_stack.top.g)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.helpers
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Implements various helpers.
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
@ -12,13 +23,13 @@ except ImportError:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
json_available = False
|
json_available = False
|
||||||
|
|
||||||
from werkzeug import Headers, wrap_file
|
from werkzeug import Headers, wrap_file
|
||||||
|
|
||||||
from flask.globals import session, _request_ctx_stack, current_app, request
|
from flask.globals import session, _request_ctx_stack, current_app, request
|
||||||
from flask.wrappers import Response
|
from flask.wrappers import Response
|
||||||
|
|
||||||
|
|
||||||
def _assert_have_json():
|
def _assert_have_json():
|
||||||
"""Helper function that fails if JSON is unavailable."""
|
"""Helper function that fails if JSON is unavailable."""
|
||||||
if not json_available:
|
if not json_available:
|
||||||
|
|
@ -35,6 +46,7 @@ if not json_available or '\\/' not in json.dumps('/'):
|
||||||
else:
|
else:
|
||||||
_tojson_filter = json.dumps
|
_tojson_filter = json.dumps
|
||||||
|
|
||||||
|
|
||||||
def jsonify(*args, **kwargs):
|
def jsonify(*args, **kwargs):
|
||||||
"""Creates a :class:`~flask.Response` with the JSON representation of
|
"""Creates a :class:`~flask.Response` with the JSON representation of
|
||||||
the given arguments with an `application/json` mimetype. The arguments
|
the given arguments with an `application/json` mimetype. The arguments
|
||||||
|
|
@ -66,7 +78,8 @@ def jsonify(*args, **kwargs):
|
||||||
_assert_have_json()
|
_assert_have_json()
|
||||||
return current_app.response_class(json.dumps(dict(*args, **kwargs),
|
return current_app.response_class(json.dumps(dict(*args, **kwargs),
|
||||||
indent=None if request.is_xhr else 2), mimetype='application/json')
|
indent=None if request.is_xhr else 2), mimetype='application/json')
|
||||||
|
|
||||||
|
|
||||||
def get_pkg_resources():
|
def get_pkg_resources():
|
||||||
"""Use pkg_resource if that works, otherwise fall back to cwd. The
|
"""Use pkg_resource if that works, otherwise fall back to cwd. The
|
||||||
current working directory is generally not reliable with the notable
|
current working directory is generally not reliable with the notable
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.module
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Implements a class that represents module blueprints.
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
from flask.helpers import _PackageBoundObject
|
from flask.helpers import _PackageBoundObject
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.session
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Implements cookie based sessions based on Werkzeug's secure cookie
|
||||||
|
system.
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
from werkzeug.contrib.securecookie import SecureCookie
|
from werkzeug.contrib.securecookie import SecureCookie
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
flask.wrappers
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Implements the WSGI wrappers (request and response).
|
||||||
|
|
||||||
|
:copyright: (c) 2010 by Armin Ronacher.
|
||||||
|
:license: BSD, see LICENSE for more details.
|
||||||
|
"""
|
||||||
|
|
||||||
from werkzeug import Request as RequestBase, Response as ResponseBase, \
|
from werkzeug import Request as RequestBase, Response as ResponseBase, \
|
||||||
cached_property
|
cached_property
|
||||||
|
|
||||||
|
|
@ -57,8 +68,3 @@ class Response(ResponseBase):
|
||||||
set :attr:`~flask.Flask.response_class` to your subclass.
|
set :attr:`~flask.Flask.response_class` to your subclass.
|
||||||
"""
|
"""
|
||||||
default_mimetype = 'text/html'
|
default_mimetype = 'text/html'
|
||||||
|
|
||||||
|
|
||||||
class _RequestGlobals(object):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -58,7 +58,7 @@ setup(
|
||||||
description='A microframework based on Werkzeug, Jinja2 '
|
description='A microframework based on Werkzeug, Jinja2 '
|
||||||
'and good intentions',
|
'and good intentions',
|
||||||
long_description=__doc__,
|
long_description=__doc__,
|
||||||
py_modules=['flask'],
|
packages=['flask'],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
platforms='any',
|
platforms='any',
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue