pyramid_jsonapi.endpoints module

Classes to store and manipulate endpoints and routes.

class pyramid_jsonapi.endpoints.EndpointData(api)[source]

Bases: object

Class to hold endpoint data and utility methods.

Parameters

api – A PyramidJSONAPI object.

add_routes_views(view)[source]

Generate routes and views from the endpoints data object.

Parameters

view – A view_class to associate routes and views with.

find_all_keys(name, ep_type, method)[source]

Generator to fetch all the instances of a particular key in part of the tree.

Parameters
  • ep_type – per-endpoint - e.g. collection, item etc.

  • method – http method

  • Returns – Yields the value of each matching key.

get_function_name(view, http_method, route_pattern)[source]

Find the name of the function which handles the given route and method.

property http_methods
property http_to_view_methods
make_route_name(name, suffix='')[source]

Attach prefix and suffix to name to generate a route_name.

Parameters

name – A pyramid route name.

Keyword Arguments

suffix – An (optional) suffix to append to the route name.

route_pattern_to_suffix(pattern_dict)[source]

Convert route_pattern dict to suffix string.

class pyramid_jsonapi.endpoints.RoutePatternConstructor(api)[source]

Bases: object

Construct pyramid_jsonapi route patterns.

create_pattern(type_prefix, endpoint_name, *components, base='/', rstrip=True)[source]

Generate a pattern from a type_prefix, endpoint name and suffix components.

This method is not usually called directly. Instead, the wrapping api_pattern and metadata_pattern partial methods are used.

Parameters
  • type_prefix (str) – api or metadataprefix (see ‘partial’ methods).

  • endpoint_name (str) – An endpoint name.

  • base (str) – Base string to prepend to pattern (defaults to ‘/’).

  • rstrip (bool) – Strip trailing separator (defaults to True).

  • *components (str) – components to add after collection name.

pattern_from_components(*components, start_sep=False, end_sep=False)[source]

Construct a route pattern from components.

Join components together with self.sep. Remove all occurrences of ‘’, and strip extra separators.

Parameters
  • *components (str) – route pattern components.

  • start_sep (bool) – Add a leading separator

  • end_sep (bool) – Add a trailing separator