mirror of https://github.com/pallets/flask.git
				
				
				
			Added missing comments, fixed setup.py and made tests pass
This commit is contained in:
		
							parent
							
								
									dd59d7241d
								
							
						
					
					
						commit
						4f8ee8f129
					
				|  | @ -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 | ||||
|  |  | |||
							
								
								
									
										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 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 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
							
								
								
									
										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 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 | ||||
|  |  | |||
|  | @ -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) | ||||
| 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 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 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue