jfinkels/flask-restless — pull request #234 by dnordberg (2013-07-31 14:15:37+00:00)
Title: Explicit declaration of exposed sub-resources.

Enables explicit declaration of exposed model sub-resources by
passing a `relationname` parameter to the `APIManager.create_api`
method.

This enables model relation endpoints to declare their own include and
exclude rules, methods, and post and pre processors.

If relationname is not passed to create_api, only the primary model
endpoints are created (e.g. /api/person, /api/person/1) you won't be
able to access other endpoints. Additional calls to create_api which
include the `relationname` parameter create the relation endpoints and
at this point include and exclude rules as well as post and pre
processors can be passed (Same as the primary model or different).

This also enables independent filtering of exposed model relation
endpoints with the same API.

This introduces two backwards incompatible changes.

1) Each exposed relation endpoint needs to be defined using `create_api`
and passing the `relationname` parameter.

2) When passing `exclude_columns`, if you wish to exclude all relational data
in a field, you only need to pass the field name, and not each field
under the relation. For example,

```exclude_columns = ['country']```

Instead of

```exclude_columns = ['country.name', 'country.code']```

This commit also updates the has_field doc string, which should also work
for `hybrid_property` fields.

Allow filtering of exposed model relation endpoints.

An example declaration exposing a primary resource and a sub-resource:

```
apimanager.create_api(Country,
methods=methods,
url_prefix="/api/v1",
results_per_page=results_per_page,
max_results_per_page=100000,
postprocessors=postprocessors_,
preprocessors=preprocessors_,
allow_functions=allow_functions,
exclude_columns=[],
include_columns=[],
relationname=relationname,
validation_exceptions=[ValidationError,
ProcessingException,
BadRequest],
)

apimanager.create_api(Country,
relationname='cities',
methods=methods,
url_prefix="/api/v1",
results_per_page=results_per_page,
max_results_per_page=100000,
postprocessors=postprocessors_,
preprocessors=preprocessors_,
allow_functions=allow_functions,
exclude_columns=[],
include_columns=[],
validation_exceptions=[ValidationError,
ProcessingException,
BadRequest],
)
```