ModelResource¶
- class flask_restful_dbbase.resources.ModelResource[source]¶
Bases:
DBBaseResourceModelResource 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.
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.
This is a convenience function for getting documentation parameters from the model class.
get_urls()This function returns something similar to
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_commitbefore_commitdecoratorsA list of decorators to apply, in order, to the generated view function.
default_sortfieldsinit_every_requestCreate a new instance of this view class for every request by default.
meta_docmethod_decoratorsThe methods this view is registered for.
model_classmodel_nameThe string version of the Model class name.
process_delete_inputprocess_get_inputprocess_patch_inputprocess_post_inputprocess_put_inputprovide_automatic_optionsControl whether the
OPTIONSmethod is handled automatically.representationsrequires_parameterserial_field_relationsserial_fieldsurl_nameurl_prefixuse_date_conversionsuse_date_conversions can be used if the database, such as SQlite3 does not support the acceptance of string-based dates.
- 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"]) asrouteandadd_url_ruleby default.