diff --git a/flask/__init__.py b/flask/__init__.py index b57e7d07..8cfe7fca 100644 --- a/flask/__init__.py +++ b/flask/__init__.py @@ -16,6 +16,7 @@ from werkzeug import abort, redirect from jinja2 import Markup, escape from flask.app import Flask +from flask.config import Config from flask.helpers import url_for, jsonify, json_available, flash, send_file, \ get_flashed_messages, render_template, render_template, render_template_string, \ get_template_attribute, json diff --git a/flask/app.py b/flask/app.py index 273e9b34..e7ed5bcb 100644 --- a/flask/app.py +++ b/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 datetime import timedelta, datetime from itertools import chain @@ -10,7 +21,7 @@ from werkzeug.exceptions import HTTPException, InternalServerError from flask.helpers import _PackageBoundObject, url_for, get_flashed_messages, \ _tojson_filter, get_pkg_resources 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.globals import _request_ctx_stack, request from flask.session import Session, _NullSession diff --git a/flask/conf.py b/flask/config.py similarity index 96% rename from flask/conf.py rename to flask/config.py index 90414155..7918de01 100644 --- a/flask/conf.py +++ b/flask/config.py @@ -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 sys diff --git a/flask/ctx.py b/flask/ctx.py index f3eab16a..1c538ecf 100644 --- a/flask/ctx.py +++ b/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 flask.wrappers import _RequestGlobals from flask.globals import _request_ctx_stack from flask.session import _NullSession +class _RequestGlobals(object): + pass + + class _RequestContext(object): """The request context contains all request relevant information. It is created at the beginning of the request and pushed to the diff --git a/flask/globals.py b/flask/globals.py index 11fdf0b3..aac46555 100644 --- a/flask/globals.py +++ b/flask/globals.py @@ -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 # context locals @@ -5,4 +17,4 @@ _request_ctx_stack = LocalStack() current_app = LocalProxy(lambda: _request_ctx_stack.top.app) request = LocalProxy(lambda: _request_ctx_stack.top.request) session = LocalProxy(lambda: _request_ctx_stack.top.session) -g = LocalProxy(lambda: _request_ctx_stack.top.g) \ No newline at end of file +g = LocalProxy(lambda: _request_ctx_stack.top.g) diff --git a/flask/helpers.py b/flask/helpers.py index 58dd2094..5a6e3966 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -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 sys import mimetypes @@ -12,13 +23,13 @@ except ImportError: import json except ImportError: json_available = False - + from werkzeug import Headers, wrap_file from flask.globals import session, _request_ctx_stack, current_app, request from flask.wrappers import Response - + def _assert_have_json(): """Helper function that fails if JSON is unavailable.""" if not json_available: @@ -35,6 +46,7 @@ if not json_available or '\\/' not in json.dumps('/'): else: _tojson_filter = json.dumps + def jsonify(*args, **kwargs): """Creates a :class:`~flask.Response` with the JSON representation of the given arguments with an `application/json` mimetype. The arguments @@ -66,7 +78,8 @@ def jsonify(*args, **kwargs): _assert_have_json() return current_app.response_class(json.dumps(dict(*args, **kwargs), indent=None if request.is_xhr else 2), mimetype='application/json') - + + def get_pkg_resources(): """Use pkg_resource if that works, otherwise fall back to cwd. The current working directory is generally not reliable with the notable diff --git a/flask/module.py b/flask/module.py index 3d691316..85898511 100644 --- a/flask/module.py +++ b/flask/module.py @@ -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 diff --git a/flask/session.py b/flask/session.py index cd0d5d29..324fc98d 100644 --- a/flask/session.py +++ b/flask/session.py @@ -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 diff --git a/flask/wrappers.py b/flask/wrappers.py index 091c708e..d962a563 100644 --- a/flask/wrappers.py +++ b/flask/wrappers.py @@ -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, \ cached_property @@ -57,8 +68,3 @@ class Response(ResponseBase): set :attr:`~flask.Flask.response_class` to your subclass. """ default_mimetype = 'text/html' - - -class _RequestGlobals(object): - pass - diff --git a/setup.py b/setup.py index 404fad32..dd3561da 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ setup( description='A microframework based on Werkzeug, Jinja2 ' 'and good intentions', long_description=__doc__, - py_modules=['flask'], + packages=['flask'], zip_safe=False, platforms='any', install_requires=[