Flask-Potion is a RESTful API framework for Flask and SQLAlchemy, Peewee or MongoEngine
fields.DateTimeString
and defaults to UTC with native datetime objects. (Thanks @albertodonato)sort_attribute
meta class attribute of a resource can be used to change the default pagination sort order, which otherwise is id_attribute
ascending. Descending order is supported. (Thanks @albertodonato and @luord)class SpamResource(Resource):
class Meta:
model = Spam
sort_attribute = 'name', True
field.Object(pattern_properties={})
pattern definitionFixes Api.decorators not being applied to "/schema"
This means if you have an authenticated API your "/schema" endpoint is no longer available to unauthenticated users.
Adds POTION_DECORATE_SCHEMA_ENDPOINTS configuration option
Setting this option to False
makes the "/schema" endpoint and "/{resource_name}/schema" endpoints available in an Api protected using Api.decorators.
Adds support for user:$id and user:$uri needs with Flask-Principal
Email
and Uri
work like String
because they inherits from it)DateString
, DateTimeString
(Thanks, @boydgreenfield)ItemUri.convert()
. This means you can now specify filters for the "$uri"
field. For more info, see below. (Thanks, @boydgreenfield)Meta.filters
Enabling filtering by "$uri"
in a resource:
class Meta:
filters = {
'$uri': {
None: filters.EqualFilter,
'eq': filters.EqualFilter,
'ne': filters.NotEqualFilter,
'in': filters.InFilter
},
'*': True
}
Note that filters
needs to correspond to the manager implementation you are using, e.g. flask_potion.contrib.alchemy.filters
. If you want to enable the filter in multiple resources, you can use a Meta mixin.
Refactored logic for inferring the id attribute and its field class type
Support for decimal.Decimal
used for Numeric fields by PostgreSQL drivers (Thanks, @brunsgaard)
Updated the configuration of fields when used with a FieldSet
:
The io
attribute on fields can now have 'c'
(create) and 'u'
(update) in addition to 'r'
and 'w'
. This allows for e.g fields that can only be written once on create 'cr'
or are generated by the server but can then be updated 'ru'
.