Fix typos and remove unused import.
This commit is contained in:
parent
9f6bc93e4d
commit
3c821a0fa4
6 changed files with 15 additions and 14 deletions
|
|
@ -111,7 +111,7 @@ side.
|
||||||
Note that we are using the :meth:`~werkzeug.MultiDict.get` method here
|
Note that we are using the :meth:`~werkzeug.MultiDict.get` method here
|
||||||
which will never fail. If the key is missing a default value (here ``0``)
|
which will never fail. If the key is missing a default value (here ``0``)
|
||||||
is returned. Furthermore it can convert values to a specific type (like
|
is returned. Furthermore it can convert values to a specific type (like
|
||||||
in our case `int`). This is especially handy for code that that is
|
in our case `int`). This is especially handy for code that is
|
||||||
triggered by a script (APIs, JavaScript etc.) because you don't need
|
triggered by a script (APIs, JavaScript etc.) because you don't need
|
||||||
special error reporting in that case.
|
special error reporting in that case.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,9 @@ And this is what `views.py` would look like::
|
||||||
.. admonition:: Circular Imports
|
.. admonition:: Circular Imports
|
||||||
|
|
||||||
Every Python programmer hates them, and yet we just added some:
|
Every Python programmer hates them, and yet we just added some:
|
||||||
circular imports (That's when two module depend on each one. In this
|
circular imports (That's when two modules depend on each other. In this
|
||||||
case `views.py` depends on `__init__.py`). Be advised that this is a
|
case `views.py` depends on `__init__.py`). Be advised that this is a
|
||||||
bad idea in general but here it is actually fine. The reason for this
|
bad idea in general but here it is actually fine. The reason for this is
|
||||||
is
|
|
||||||
that we are not actually using the views in `__init__.py` and just
|
that we are not actually using the views in `__init__.py` and just
|
||||||
ensuring the module is imported and we are doing that at the bottom of
|
ensuring the module is imported and we are doing that at the bottom of
|
||||||
the file.
|
the file.
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,8 @@ def user_timeline(username):
|
||||||
if g.user:
|
if g.user:
|
||||||
followed = query_db('''select 1 from follower where
|
followed = query_db('''select 1 from follower where
|
||||||
follower.who_id = ? and follower.whom_id = ?''',
|
follower.who_id = ? and follower.whom_id = ?''',
|
||||||
[session['user_id'], profile_user['user_id']], one=True) is not None
|
[session['user_id'], profile_user['user_id']],
|
||||||
|
one=True) is not None
|
||||||
return render_template('timeline.html', messages=query_db('''
|
return render_template('timeline.html', messages=query_db('''
|
||||||
select message.*, user.* from message, user where
|
select message.*, user.* from message, user where
|
||||||
user.user_id = message.author_id and user.user_id = ?
|
user.user_id = message.author_id and user.user_id = ?
|
||||||
|
|
@ -230,7 +231,7 @@ def register():
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
def logout():
|
def logout():
|
||||||
"""Logs the user out"""
|
"""Logs the user out."""
|
||||||
flash('You were logged out')
|
flash('You were logged out')
|
||||||
session.pop('user_id', None)
|
session.pop('user_id', None)
|
||||||
return redirect(url_for('public_timeline'))
|
return redirect(url_for('public_timeline'))
|
||||||
|
|
|
||||||
9
flask.py
9
flask.py
|
|
@ -10,7 +10,6 @@
|
||||||
:license: BSD, see LICENSE for more details.
|
:license: BSD, see LICENSE for more details.
|
||||||
"""
|
"""
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -261,7 +260,7 @@ def _default_template_ctx_processor():
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
raise RuntimeError('simplejson not installed')
|
raise RuntimeError('simplejson not installed')
|
||||||
|
|
||||||
|
|
@ -517,7 +516,7 @@ class Flask(object):
|
||||||
|
|
||||||
def add_url_rule(self, rule, endpoint, view_func=None, **options):
|
def add_url_rule(self, rule, endpoint, view_func=None, **options):
|
||||||
"""Connects a URL rule. Works exactly like the :meth:`route`
|
"""Connects a URL rule. Works exactly like the :meth:`route`
|
||||||
decorator. If a view_func is provided it will be registered with the
|
decorator. If a view_func is provided it will be registered with the
|
||||||
endpoint.
|
endpoint.
|
||||||
|
|
||||||
Basically this example::
|
Basically this example::
|
||||||
|
|
@ -544,7 +543,7 @@ class Flask(object):
|
||||||
:param endpoint: the endpoint for the registered URL rule. Flask
|
:param endpoint: the endpoint for the registered URL rule. Flask
|
||||||
itself assumes the name of the view function as
|
itself assumes the name of the view function as
|
||||||
endpoint
|
endpoint
|
||||||
:param view_func: the function to call when servicing a request to the
|
:param view_func: the function to call when serving a request to the
|
||||||
provided endpoint
|
provided endpoint
|
||||||
:param options: the options to be forwarded to the underlying
|
:param options: the options to be forwarded to the underlying
|
||||||
:class:`~werkzeug.routing.Rule` object
|
:class:`~werkzeug.routing.Rule` object
|
||||||
|
|
@ -798,7 +797,7 @@ class Flask(object):
|
||||||
return self.request_context(create_environ(*args, **kwargs))
|
return self.request_context(create_environ(*args, **kwargs))
|
||||||
|
|
||||||
def __call__(self, environ, start_response):
|
def __call__(self, environ, start_response):
|
||||||
"""Shortcut for :attr:`wsgi_app`"""
|
"""Shortcut for :attr:`wsgi_app`."""
|
||||||
return self.wsgi_app(environ, start_response)
|
return self.wsgi_app(environ, start_response)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
6
setup.py
6
setup.py
|
|
@ -34,7 +34,8 @@ Links
|
||||||
|
|
||||||
* `website <http://flask.pocoo.org/>`_
|
* `website <http://flask.pocoo.org/>`_
|
||||||
* `documentation <http://flask.pocoo.org/docs/>`_
|
* `documentation <http://flask.pocoo.org/docs/>`_
|
||||||
* `development version <http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_
|
* `development version
|
||||||
|
<http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
@ -47,7 +48,8 @@ setup(
|
||||||
license='BSD',
|
license='BSD',
|
||||||
author='Armin Ronacher',
|
author='Armin Ronacher',
|
||||||
author_email='armin.ronacher@active-4.com',
|
author_email='armin.ronacher@active-4.com',
|
||||||
description='A microframework based on Werkzeug, Jinja2 and good intentions',
|
description='A microframework based on Werkzeug, Jinja2 '
|
||||||
|
'and good intentions',
|
||||||
long_description=__doc__,
|
long_description=__doc__,
|
||||||
py_modules=['flask'],
|
py_modules=['flask'],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue