Permalink
Browse files

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

  • Loading branch information...
1 parent dd59d72 commit 4f8ee8f12946b224e5003405be99aa4e454bdeee @mitsuhiko mitsuhiko committed Jul 4, 2010
Showing with 103 additions and 12 deletions.
  1. +1 −0 flask/__init__.py
  2. +12 −1 flask/app.py
  3. +11 −0 flask/{conf.py → config.py}
  4. +15 −1 flask/ctx.py
  5. +13 −1 flask/globals.py
  6. +16 −3 flask/helpers.py
  7. +11 −0 flask/module.py
  8. +12 −0 flask/session.py
  9. +11 −5 flask/wrappers.py
  10. +1 −1 setup.py
View
@@ -16,6 +16,7 @@
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
View
@@ -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 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
@@ -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
View
@@ -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
View
@@ -1,8 +1,20 @@
+# -*- 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
_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)
+g = LocalProxy(lambda: _request_ctx_stack.top.g)
View
@@ -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 @@
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 @@ def _tojson_filter(*args, **kwargs):
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 get_current_user():
_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
View
@@ -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
View
@@ -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
View
@@ -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
-
View
@@ -58,7 +58,7 @@ def run_tests():
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=[

0 comments on commit 4f8ee8f

Please sign in to comment.