pyramid_jsonapi.callbacks_doc module

pyramid_jsonapi.callbacks_doc.after_collection_get(view_instance, document)[source]

Called just before view_instance.collection_get() returns.

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • document (dict) – JSON-API top level document.

Returns

altered JSON-API top level document.

Return type

dict

pyramid_jsonapi.callbacks_doc.after_get(view_instance, document)[source]

Called just before view_instance.get() returns.

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • document (dict) – JSON-API top level document.

Returns

altered JSON-API top level document.

Return type

dict

Called before view_instance.related_get() returns.

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • document (dict) – JSON-API top level document.

Returns

altered JSON-API top level document.

Return type

dict

pyramid_jsonapi.callbacks_doc.after_relationships_get(view_instance, document)[source]

Called before view_instance.relationships_get() returns.

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • document (dict) – JSON-API top level document.

Returns

altered JSON-API top level document.

Return type

dict

pyramid_jsonapi.callbacks_doc.after_serialise_identifier(view_instance, identifier)[source]

Called after a resource identifier is serialised, before it is returned.

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • identifier (dict) – serialised identifier.

Returns

serialised resource identifier.

Return type

dict

pyramid_jsonapi.callbacks_doc.after_serialise_object(view_instance, obj)[source]

Called after a resource object is serialised, before it is returned.

Use this callback to alter objects as they are serialised: perhaps merging information from other data sources, perhaps removing restricted information or denying access (raise an appropriate exception).

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • obj (dict) – serialised object.

Returns

serialised resource object.

Return type

dict

pyramid_jsonapi.callbacks_doc.before_collection_post(view_instance, obj)[source]

Called before enacting view_instance.collection_post().

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • obj (dict) – JSON-API object to be created.

pyramid_jsonapi.callbacks_doc.before_delete(view_instance, db_item)[source]

Called before an object is deleted.

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • db_item – item returned by sqlalchemy query.

pyramid_jsonapi.callbacks_doc.before_patch(view_instance, partial_object)[source]

Called before a patch is applied.

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • partial_object (dict) – JSON-API patch object.

Returns

altered patch object.

Return type

dict

pyramid_jsonapi.callbacks_doc.before_relationships_delete(view_instance, parent_db_item)[source]
pyramid_jsonapi.callbacks_doc.before_relationships_patch(view_instance, data)[source]

Called before enacting view_instance.relationships_patch().

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • data (dict or list) – resource identifier or a list of them.

pyramid_jsonapi.callbacks_doc.before_relationships_post(view_instance, data)[source]

Called before enacting view_instance.relationships_post().

Parameters
  • view_instance (pyramid_jsonapi.CollectionViewBase) – the current view instance.

  • data (dict or list) – resource identifier or a list of them.