Utilities

General utilities used within Repose.

For the most part these can be ignored, their usage is mainly for internal purposes.

class repose.utilities.LazyList(generator=None, size=0)

Wraps a generator from which data is only loaded when needed.

Todo

The LazyList loading logic could be more intelligent

Todo

Make the size parameter optional

__init__(generator=None, size=0)

Initialise the LazyList

Parameters:
  • generator (generator) – The generator to be lazy loaded
  • size (int) – The size of the list to be loaded
repose.utilities.get_values_from_endpoint(resource, endpoint_params)

Determine if any values in the endpoint parameters should be used to populate fields.

An example of this would be resources which don’t provide their own ID in the return data, and it must therefore come from the endpoint used to access the resource. In which case, you may define the resource’s ID field as:

id = fields.Integer(from_endpoint='id')
Parameters:
  • resource (repose.resources.Resource) – The class of the resource being populated
  • endpoint_params (dict) – All parameters available for formatting to the endpoint strings.
repose.utilities.make_endpoint(model)

Make an endpoint for a given model

See the repose.resources.Resource.Meta for a description of endpoint URL formatting.