ModelResource

class flask_restful_dbbase.resources.ModelResource[source]

Bases: DBBaseResource

ModelResource Class

This model class implements the base class.

Class variables:

model_class: a dbbase.Model

url_prefix: the portion of the path leading up to the resource

For example: /api/v2

url_name: the url_name defaults to a lower case version of the

the model_class name if left as None, but can have an explicit name if necessary.

serial_fields: if left as None, it uses the serial list from

the model class. However, it can be a list of field names or

before_commit: A dict with method keys for placing a function

to run just before committing an item to the database. It can also divert the method to end the HTTP method early and return something entirely different than the item being applied.

after_commit: A dict with method keys for placing a function

to run just afteer committing an item to the database. It can also divert the method to end the HTTP method early and return something entirely different than the item being applied.

Methods

as_view(name, *class_args, **class_kwargs)

Convert the class into a view function that can be registered for a route.

create_url()

Url can come from: * url_name resource variable

delete(**kwargs)

This function is the HTTP DELETE method for a resource handling a single item.

dispatch_request(*args, **kwargs)

The actual view function behavior.

format_key(key, key_type)

This function returns the portion of the URL that embodies the key.

get(**kwargs)

This function is the HTTP GET method for a resource handling a single item.

get_key_names([formatted])

This function returns column names marked as primary_key.

get_meta([method])

This function returns the settings for the resource.

get_obj_params()

This is a convenience function for getting documentation parameters from the model class.

get_urls()

This function returns something similar to

is_collection()

This function returns True if identified as a collection resource.

patch(**kwargs)

This function is the HTTP PATCH method for a resource handling a single item.

post()

This function is the HTTP POST method for a resource handling a single item.

put(**kwargs)

This function is the HTTP PUT method for a resource handling a single item.

screen_data(data, obj_params[, ...])

Assumes data is deserialized

Attributes

after_commit

before_commit

decorators

A list of decorators to apply, in order, to the generated view function.

default_sort

fields

init_every_request

Create a new instance of this view class for every request by default.

meta_doc

method_decorators

methods

The methods this view is registered for.

model_class

model_name

The string version of the Model class name.

process_delete_input

process_get_input

process_patch_input

process_post_input

process_put_input

provide_automatic_options

Control whether the OPTIONS method is handled automatically.

representations

requires_parameter

serial_field_relations

serial_fields

url_name

url_prefix

use_date_conversions

use_date_conversions can be used if the database, such as SQlite3 does not support the acceptance of string-based dates.

get(**kwargs)[source]

This function is the HTTP GET method for a resource handling a single item.

post()[source]

This function is the HTTP POST method for a resource handling a single item.

put(**kwargs)[source]

This function is the HTTP PUT method for a resource handling a single item.

patch(**kwargs)[source]

This function is the HTTP PATCH method for a resource handling a single item.

delete(**kwargs)[source]

This function is the HTTP DELETE method for a resource handling a single item.

methods = {'DELETE', 'GET', 'PATCH', 'POST', 'PUT'}

The methods this view is registered for. Uses the same default (["GET", "HEAD", "OPTIONS"]) as route and add_url_rule by default.