Hyphenate "class-based"
Before adoption: this commit came in with the history the project adopted, so no landing records it.
makes it more readable
authored by FND · committed by FND · parent 5cb50a4 · Browse files · 5 files·+11 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+11 added−11 removed
- other:+11 added−11 removed
Provenance
- Commit
4aebc26- Tree
c695643- Author
FND <fnd@fnd-oda.(none)>- Committer
FND <fnd@fnd-oda.(none)>- Parent
5cb50a4
5 files changed+11 added−11 removed
modified:docs/api.rst+1 added-1 removed
474 unmodified lines475 operations, including connecting.476 477 .. _blinker: http://pypi.python.org/pypi/blinker478 479-Class Based Views479+Class-Based Views480 -----------------481 482 .. versionadded:: 0.7483 145 unmodified linesmodified:docs/extensiondev.rst+2 added-2 removed
146 unmodified lines147 some helper functions like `OAuth.remote_app` to create a reference to148 a remote application that uses OAuth.149 150 What to use depends on what you have in mind. For the SQLite 3 extension151-we will use the class based approach because it will provide users with a151+we will use the class-based approach because it will provide users with a152 manager object that handles opening and closing database connections.153 154 The Extension Code155 ------------------46 unmodified lines202 `g` object to store things like database connections.203 5. Finally, we add a `get_db` function that simplifies access to the context's204 database.205 206-So why did we decide on a class based approach here? Because using our206+So why did we decide on a class-based approach here? Because using our207 extension looks something like this::208 209 from flask import Flask210 from flask_sqlite3 import SQLite3177 unmodified linesmodified:docs/views.rst+2 added-2 removed
21 unmodified lines22 return render_template('users.html', users=users)23 24 This is simple and flexible, but if you want to provide this view in a25 generic fashion that can be adapted to other models and templates as well26-you might want more flexibility. This is where pluggable class based26+you might want more flexibility. This is where pluggable class-based27 views come into place. As the first step to convert this into a class28 based view you would do this::29 30 38 unmodified lines69 def get_objects(self):70 return User.query.all()71 72 This of course is not that helpful for such a small example, but it's good73-enough to explain the basic principle. When you have a class based view73+enough to explain the basic principle. When you have a class-based view74 the question comes up what `self` points to. The way this works is that75 whenever the request is dispatched a new instance of the class is created76 and the :meth:`~flask.views.View.dispatch_request` method is called with77 the parameters from the URL rule. The class itself is instantiated with160 unmodified linesmodified:flask/views.py+4 added-4 removed
1 unmodified line2 """3 flask.views4 ~~~~~~~~~~~5 6- This module provides class based views inspired by the ones in Django.6+ This module provides class-based views inspired by the ones in Django.7 8 :copyright: (c) 2011 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10 """38 unmodified lines49 50 #: A for which methods this pluggable view can handle.51 methods = None52 53- #: The canonical way to decorate class based views is to decorate the53+ #: The canonical way to decorate class-based views is to decorate the54 #: return value of as_view(). However since this moves parts of the55 #: logic from the class declaration to the place where it's hooked56 #: into the routing system.57 #:30 unmodified lines88 for decorator in cls.decorators:89 view = decorator(view)90 91 # we attach the view class to the view function for two reasons:92- # first of all it allows us to easily figure out what class based92+ # first of all it allows us to easily figure out what class-based93 # view this thing came from, secondly it's also used for instantiating94 # the view class so you can actually replace it with something else95 # for testing purposes and debugging.96 view.view_class = cls22 unmodified lines119 return rv120 121 122 class MethodView(View):123- """Like a regular class based view but that dispatches requests to123+ """Like a regular class-based view but that dispatches requests to124 particular methods. For instance if you implement a method called125 :meth:`get` it means you will response to ``'GET'`` requests and126 the :meth:`dispatch_request` implementation will automatically127 forward your request to that. Also :attr:`options` is set for you23 unmodified linesmodified:CHANGES+2 added-2 removed
87 unmodified lines88 - Refactored test client internally. The ``APPLICATION_ROOT`` configuration89 variable as well as ``SERVER_NAME`` are now properly used by the test client90 as defaults.91 - Added :attr:`flask.views.View.decorators` to support simpler decorating of92- pluggable (class based) views.92+ pluggable (class-based) views.93 - Fixed an issue where the test client if used with the "with" statement did not94 trigger the execution of the teardown handlers.95 - Added finer control over the session cookie parameters.96 - HEAD requests to a method view now automatically dispatch to the `get`79 unmodified lines176 provide custom error messages from a central hub for certain errors that177 might occur during request processing (for instance database connection178 errors, timeouts from remote resources etc.).179 - Blueprints can provide blueprint specific error handlers.180-- Implemented generic :ref:`views` (class based views).180+- Implemented generic :ref:`views` (class-based views).181 182 Version 0.6.1183 -------------184 159 unmodified lines