Permalink
Browse files

Merge branch 'master' into merged-features

  • Loading branch information...
2 parents c80eeae + 7a87cad commit 9795e7aecb865d8ec8133d82c0f8e6c8fac19bec Libor Nenadál committed Jun 16, 2012
Showing with 11 additions and 11 deletions.
  1. +3 −3 flask_restless/manager.py
  2. +6 −6 flask_restless/views.py
  3. +2 −2 tests/test_views.py
@@ -195,7 +195,7 @@ def create_api_blueprint(self, model, methods=READONLY_METHODS,
authentication_function=None,
include_columns=None, validation_exceptions=None,
results_per_page=10,
- post_method_decorator_function=None):
+ post_form_preprocessor=None):
"""Creates an returns a ReSTful API interface as a blueprint, but does
not register it on any :class:`flask.Flask` application.
@@ -284,7 +284,7 @@ def create_api_blueprint(self, model, methods=READONLY_METHODS,
positive integer, pagination will be disabled (warning: this may result
in large responses). For more information, see :ref:`pagination`.
- `post_method_decorator_function` is a callback function which takes
+ `post_form_preprocessor` is a callback function which takes
POST input parameters loaded from JSON and enhances them with other
key/value pairs. The example use of this is when your ``model``
requires to store user identity and for security reasons the identity
@@ -337,7 +337,7 @@ def create_api_blueprint(self, model, methods=READONLY_METHODS,
authentication_required_for,
authentication_function, include_columns,
validation_exceptions, results_per_page,
- post_method_decorator_function)
+ post_form_preprocessor)
# suffix an integer to apiname according to already existing blueprints
blueprintname = self._next_blueprint_name(apiname)
# add the URL rules to the blueprint: the first is for methods on the
View
@@ -380,7 +380,7 @@ class API(ModelView):
def __init__(self, session, model, authentication_required_for=None,
authentication_function=None, include_columns=None,
validation_exceptions=None, results_per_page=10,
- post_method_decorator_function=None, *args, **kw):
+ post_form_preprocessor=None, *args, **kw):
"""Instantiates this view with the specified attributes.
`session` is the SQLAlchemy session in which all database transactions
@@ -421,7 +421,7 @@ def __init__(self, session, model, authentication_required_for=None,
positive integer, pagination will be disabled (warning: this may result
in large responses). For more information, see :ref:`pagination`.
- `post_method_decorator_function` is a callback function which takes
+ `post_form_preprocessor` is a callback function which takes
POST input parameters loaded from JSON and enhances them with other
key/value pairs. The example use of this is when your ``model``
requires to store user identity and for security reasons the identity
@@ -451,7 +451,7 @@ def __init__(self, session, model, authentication_required_for=None,
self.results_per_page = results_per_page
self.paginate = (isinstance(self.results_per_page, int)
and self.results_per_page > 0)
- self.post_method_decorator_function = post_method_decorator_function
+ self.post_form_preprocessor = post_form_preprocessor
def _get_child_relation(self, instid, relation):
instance = self._get_by(instid)
@@ -885,9 +885,9 @@ def post(self):
except (TypeError, ValueError, OverflowError):
return jsonify_status_code(400, message='Unable to decode data')
- # If post_method_decorator_function is specified, call it
- if self.post_method_decorator_function:
- params = self.post_method_decorator_function(params)
+ # If post_form_preprocessor is specified, call it
+ if self.post_form_preprocessor:
+ params = self.post_form_preprocessor(params)
# Getting the list of relations that will be added later
cols = _get_columns(self.model)
View
@@ -831,7 +831,7 @@ def test_alternate_primary_key(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(loads(response.data), dict(name='Earth'))
- def test_post_method_decorator_function(self):
+ def test_post_form_preprocessor(self):
"""Tests POST method decoration using a custom function."""
def decorator_function(params):
if params:
@@ -842,7 +842,7 @@ def decorator_function(params):
# test for function that decorates parameters with 'other' attribute
self.manager.create_api(self.Person, methods=['POST'],
url_prefix='/api/v2',
- post_method_decorator_function=decorator_function)
+ post_form_preprocessor=decorator_function)
response = self.app.post('/api/v2/person',
data=dumps({'name': u'Lincoln', 'age': 23}))

0 comments on commit 9795e7a

Please sign in to comment.