Added missing comments, fixed setup.py and made tests pass

This commit is contained in:
Armin Ronacher 2010-07-04 11:35:20 +02:00
parent dd59d7241d
commit 4f8ee8f129
10 changed files with 103 additions and 12 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
@ -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
@ -67,6 +79,7 @@ def jsonify(*args, **kwargs):
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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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=[