Skip to content

Commit

Permalink
fix references to flask.ext.* (fixes flask-restful#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshfriend committed Mar 22, 2015
1 parent 6255cad commit 8bdba92
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 56 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
API Docs
========

.. module:: flask.ext.restful
.. module:: flask_restful


.. autofunction:: marshal
Expand Down
10 changes: 5 additions & 5 deletions docs/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Extending Flask-RESTful
=======================

.. currentmodule:: flask.ext.restful
.. currentmodule:: flask_restful

We realize that everyone has different needs in a REST framework.
Flask-RESTful tries to be as flexible as possible, but sometimes you might
Expand Down Expand Up @@ -150,7 +150,7 @@ provide your own output functions. ::
Resource Method Decorators
--------------------------

There is a property on the :class:`~flask.ext.restful.Resource` class called
There is a property on the :class:`~flask_restful.Resource` class called
``method_decorators``. You can subclass the Resource and add your own
decorators that will be added to all ``method`` functions in resource. For
instance, if you want to build custom authentication into every request. ::
Expand Down Expand Up @@ -183,11 +183,11 @@ Error handling is a tricky problem. Your Flask application may be wearing
multiple hats, yet you want to handle all Flask-RESTful errors with the correct
content type and error syntax as your 200-level requests.

Flask-RESTful will call the :meth:`~flask.ext.restful.Api.handle_error`
Flask-RESTful will call the :meth:`~flask_restful.Api.handle_error`
function on any 400 or 500 error that happens on a Flask-RESTful route, and
leave other routes alone. You may want your app to return an error message with
the correct media type on 404 Not Found errors; in which case, use the
`catch_all_404s` parameter of the :class:`~flask.ext.restful.Api` constructor. ::
`catch_all_404s` parameter of the :class:`~flask_restful.Api` constructor. ::

app = Flask(__name__)
api = flask_restful.Api(app, catch_all_404s=True)
Expand Down Expand Up @@ -228,7 +228,7 @@ Including the `'status'` key will set the Response's status code. If not
specified it will default to 500.

Once your ``errors`` dictionary is defined, simply pass it to the
:class:`~flask.ext.restful.Api` constructor. ::
:class:`~flask_restful.Api` constructor. ::

app = Flask(__name__)
api = flask_restful.Api(app, errors=errors)
16 changes: 8 additions & 8 deletions docs/fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Output Fields
===============

.. currentmodule:: flask.ext.restful
.. currentmodule:: flask_restful


Flask-RESTful provides an easy way to control what data you actually render in
Expand All @@ -24,7 +24,7 @@ will format & return the value for that field. This example has three fields:
two are :class:`~fields.String` and one is a :class:`~fields.DateTime`,
formatted as an RFC 822 date string (ISO 8601 is supported as well) ::

from flask.ext.restful import Resource, fields, marshal_with
from flask_restful import Resource, fields, marshal_with

resource_fields = {
'name': fields.String,
Expand Down Expand Up @@ -52,8 +52,8 @@ Note: :class:`marshal_with` is a convenience decorator, that is functionally
equivalent to ::

class Todo(Resource):
def get(self, **kwargs):
return marshal(db_get_todo(), resource_fields), 200
def get(self, **kwargs):
return marshal(db_get_todo(), resource_fields), 200

This explicit expression can be used to return HTTP status codes other than 200
along with a successful response (see :func:`abort` for errors).
Expand All @@ -70,7 +70,7 @@ name. To configure this mapping, use the ``attribute`` keyword argument. ::
'address': fields.String,
}

A lambda can also be specified as the ``attribute`` ::
A lambda (or any callable) can also be specified as the ``attribute`` ::

fields = {
'name': fields.String(attribute=lambda x: x._private_name),
Expand Down Expand Up @@ -154,7 +154,7 @@ Complex Structures
You can have a flat structure that :meth:`marshal` will
transform to a nested structure ::

>>> from flask.ext.restful import fields, marshal
>>> from flask_restful import fields, marshal
>>> import json
>>>
>>> resource_fields = {'name': fields.String}
Expand All @@ -179,7 +179,7 @@ List Field

You can also unmarshal fields as lists ::

>>> from flask.ext.restful import fields, marshal
>>> from flask_restful import fields, marshal
>>> import json
>>>
>>> resource_fields = {'name': fields.String, 'first_names': fields.List(fields.String)}
Expand All @@ -196,7 +196,7 @@ While nesting fields using dicts can turn a flat data object into a nested
response, you can use :class:`~fields.Nested` to unmarshal nested data
structures and render them appropriately. ::

>>> from flask.ext.restful import fields, marshal
>>> from flask_restful import fields, marshal
>>> import json
>>>
>>> address_fields = {}
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Flask-RESTful
=============

.. module:: flask.ext.restful
.. module:: flask_restful

**Flask-RESTful** is an extension for Flask that adds support for quickly
building REST APIs. It is a lightweight abstraction that works with your
existing ORM/libraries. Flask-RESTful encourages best practices with minimal
setup. If you are familiar with Flask, Flask-RESTful should be easy to pick up.
setup. If you are familiar with Flask, Flask-RESTful should be easy to pick up.

.. include:: contents.rst.inc
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation
============

.. currentmodule:: flask.ext.restful
.. currentmodule:: flask_restful

Install Flask-RESTful with ``pip`` ::

Expand Down
17 changes: 8 additions & 9 deletions docs/intermediate-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Intermediate Usage
==================

.. currentmodule:: flask.ext.restful
.. currentmodule:: flask_restful

This page covers building a slightly more complex Flask-RESTful app that will
cover out some best practices when setting up a real-world Flask-RESTful-based
Expand Down Expand Up @@ -42,9 +42,9 @@ example, any custom input/output types your resources need to get the job done.
In the resource files, you just have your resource objects. So here's what
``foo.py`` might look like: ::

from flask.ext import restful
from flask_restful import Resource

class Foo(restful.Resource):
class Foo(Resource):
def get(self):
pass
def post(self):
Expand All @@ -53,13 +53,13 @@ In the resource files, you just have your resource objects. So here's what
The key to this setup lies in ``app.py``: ::

from flask import Flask
from flask.ext import restful
from flask_restful import Api
from myapi.resources.foo import Foo
from myapi.resources.bar import Bar
from myapi.resources.baz import Baz

app = Flask(__name__)
api = restful.Api(app)
api = Api(app)

api.add_resource(Foo, '/Foo', '/Foo/<str:id>')
api.add_resource(Bar, '/Bar', '/Bar/<str:id>')
Expand All @@ -82,7 +82,7 @@ why you should use them. Here's an example of how to link an :class:`Api`
up to a :class:`~flask.Blueprint`. ::

from flask import Flask, Blueprint
from flask.ext.restful import Api, Resource, url_for
from flask_restful import Api, Resource, url_for

app = Flask(__name__)
api_bp = Blueprint('api', __name__)
Expand All @@ -106,8 +106,7 @@ Elsewhere in the documentation, we've described how to use the reqparse example
in detail. Here we'll set up a resource with multiple input parameters that
exercise a larger amount of options. We'll define a resource named "User". ::

from flask.ext import restful
from flask.ext.restful import fields, marshal_with, reqparse
from flask_restful import fields, marshal_with, reqparse, Resource

def email(email_str):
""" return True if email_str is a valid email """
Expand Down Expand Up @@ -147,7 +146,7 @@ exercise a larger amount of options. We'll define a resource named "User". ::
}),
}

class User(restful.Resource):
class User(Resource):

@marshal_with(user_fields)
def post(self):
Expand Down
16 changes: 8 additions & 8 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Quickstart
==========

.. currentmodule:: flask.ext.restful
.. currentmodule:: flask_restful

It's time to write your first REST API. This guide assumes you have a working
understanding of `Flask <http://flask.pocoo.org>`_, and that you have already
Expand All @@ -18,12 +18,12 @@ A Minimal API
A minimal Flask-RESTful API looks like this: ::

from flask import Flask
from flask.ext import restful
from flask_restful import Resource, Api

app = Flask(__name__)
api = restful.Api(app)
api = Api(app)

class HelloWorld(restful.Resource):
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}

Expand Down Expand Up @@ -62,7 +62,7 @@ your resource. A basic CRUD resource for a todo application (of course) looks
like this: ::

from flask import Flask, request
from flask.ext.restful import Resource, Api
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)
Expand Down Expand Up @@ -152,7 +152,7 @@ form encoded data), it's still a pain to validate form data. Flask-RESTful
has built-in support for request data validation using a library similar to
`argparse <http://docs.python.org/dev/library/argparse.html>`_. ::

from flask.ext.restful import reqparse
from flask_restful import reqparse

parser = reqparse.RequestParser()
parser.add_argument('rate', type=int, help='Rate to charge for this resource')
Expand Down Expand Up @@ -190,7 +190,7 @@ problem, Flask-RESTful provides the :class:`fields` module and the
use the ``fields`` module to describe the structure of your response. ::

from collections import OrderedDict
from flask.ext.restful import fields, marshal_with
from flask_restful import fields, marshal_with

resource_fields = {
'task': fields.String,
Expand Down Expand Up @@ -224,7 +224,7 @@ Full Example
Save this example in api.py ::

from flask import Flask
from flask.ext.restful import reqparse, abort, Api, Resource
from flask_restful import reqparse, abort, Api, Resource

app = Flask(__name__)
api = Api(app)
Expand Down
6 changes: 3 additions & 3 deletions docs/reqparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Request Parsing
===============

.. currentmodule:: flask.ext.restful
.. currentmodule:: flask_restful

Flask-RESTful's request parsing interface, :mod:`reqparse`, is modeled after
the `argparse <http://docs.python.org/dev/library/argparse.html>`_ interface.
Expand All @@ -17,7 +17,7 @@ Here's a simple example of the request parser. It looks for two arguments in
the :attr:`flask.Request.values` dict: one of type ``int``, and the other of
type ``str`` ::

from flask.ext.restful import reqparse
from flask_restful import reqparse

parser = reqparse.RequestParser()
parser.add_argument('rate', type=int, help='Rate cannot be converted')
Expand Down Expand Up @@ -117,7 +117,7 @@ also overwrite any argument in the parent with
:meth:`~reqparse.RequestParser.replace_argument`, or remove it completely
with :meth:`~reqparse.RequestParser.remove_argument`. For example: ::

from flask.ext.restful import RequestParser
from flask_restful import RequestParser

parser = RequestParser()
parser.add_argument('foo', type=int)
Expand Down
2 changes: 1 addition & 1 deletion examples/todo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import Flask
from flask.ext.restful import reqparse, abort, Api, Resource
from flask_restful import reqparse, abort, Api, Resource

app = Flask(__name__)
api = Api(app)
Expand Down
2 changes: 1 addition & 1 deletion examples/todo_simple.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import Flask, request
from flask.ext.restful import Resource, Api
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)
Expand Down
2 changes: 1 addition & 1 deletion examples/xml_representation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# needs: pip install python-simplexml
from simplexml import dumps
from flask import make_response, Flask
from flask.ext.restful import Api, Resource
from flask_restful import Api, Resource

def output_xml(data, code, headers=None):
"""Makes a Flask response with a XML encoded body"""
Expand Down
Loading

0 comments on commit 8bdba92

Please sign in to comment.