Panoptes

Panoptes Userify

This module provides a function to Fetch specific information from panoptes about all users whose ids appear in the provided object.

exception panoptes_aggregation.panoptes.userify.ConfigurationError

Indicates that no destination was provided or an unknown destination was provided

panoptes_aggregation.panoptes.userify.userify(all_args, service_payload)

Augment service_payload with panoptes user data specified in all_args and post it to the specified endpoint

Parameters:
  • all_args (dict) – A dictionary containing the key/value pairs from the querystring; these represent either certain predefined fields like destination or the names of fields to be retrieved from the User objects

  • service_payload (dict) – A dictionary containing an object vivified from a JSON string in the request body. This entire object graph will be searched for all occurrences of user_id and user_ids and any object that has either will be populated with a users array containing the requested fields

Returns:

service_payload – The original service_payload object, augmented with User arrays for each object in the object graph with a user_id or user_ids field.

Return type:

dict

Examples

>>> userify({'login': None, 'destination': 'mast'}, {
    'some_field': 'some_value',
    'user_ids': [[1, 2], 3],
    'another_field': 'another_value'
})
{
    'some_field': 'some_value',
    'user_ids': [[1, 2], 3],
    'another_field': 'another_value',
    'users': [
        {'id': 1, 'login': 'login 1'},
        {'id': 2, 'login': 'login 2'},
        {'id': 3, 'login': 'login 3'}
    ]
}