The tacker.api.api_common Module

class tacker.api.api_common.NoPaginationHelper(request, primary_key=’id’)

Bases: tacker.api.api_common.PaginationHelper

class tacker.api.api_common.NoSortingHelper(request, attr_info)

Bases: tacker.api.api_common.SortingHelper

class tacker.api.api_common.PaginationEmulatedHelper(request, primary_key=’id’)

Bases: tacker.api.api_common.PaginationHelper

paginate(items)
update_fields(original_fields, fields_to_add)
class tacker.api.api_common.PaginationHelper(request, primary_key=’id’)

Bases: object

paginate(items)
update_args(args)
update_fields(original_fields, fields_to_add)
class tacker.api.api_common.PaginationNativeHelper(request, primary_key=’id’)

Bases: tacker.api.api_common.PaginationEmulatedHelper

paginate(items)
update_args(args)
class tacker.api.api_common.SortingEmulatedHelper(request, attr_info)

Bases: tacker.api.api_common.SortingHelper

sort(items)
update_fields(original_fields, fields_to_add)
class tacker.api.api_common.SortingHelper(request, attr_info)

Bases: object

sort(items)
update_args(args)
update_fields(original_fields, fields_to_add)
class tacker.api.api_common.SortingNativeHelper(request, attr_info)

Bases: tacker.api.api_common.SortingHelper

update_args(args)
class tacker.api.api_common.TackerController(plugin)

Bases: object

Base controller class for Tacker API.

tacker.api.api_common.convert_exception_to_http_exc(e, faults, language)
tacker.api.api_common.get_exception_data(e)

Extract the information about an exception.

Tacker client for the v1 API expects exceptions to have ‘type’, ‘message’ and ‘detail’ attributes.This information is extracted and converted into a dictionary.

Parameters:e – the exception to be reraised
Returns:a structured dict with the exception data
tacker.api.api_common.get_filters(request, attr_info, skips=None)

Extracts the filters from the request string.

Returns a dict of lists for the filters: check=a&check=b&name=Bob& becomes: {‘check’: [u’a’, u’b’], ‘name’: [u’Bob’]}

tacker.api.api_common.get_limit_and_marker(request)

Return marker, limit tuple from request.

Parameters:requestwsgi.Request possibly containing ‘marker’ and ‘limit’ GET variables. ‘marker’ is the id of the last element the client has seen, and ‘limit’ is the maximum number of items to return. If limit == 0, it means we needn’t pagination, then return None.
tacker.api.api_common.get_page_reverse(request)
tacker.api.api_common.get_sorts(request, attr_info)

Extract sort_key and sort_dir from request.

Return as: [(key1, value1), (key2, value2)]

tacker.api.api_common.list_args(request, arg)

Extracts the list of arg from request.

tacker.api.api_common.translate(translatable, locale)

Translates the object to the given locale.

If the object is an exception its translatable elements are translated in place, if the object is a translatable string it is translated and returned. Otherwise, the object is returned as-is.

Parameters:
  • translatable – the object to be translated
  • locale – the locale to translate to
Returns:

the translated object, or the object as-is if it was not translated