'Extract common data from the current request and context
This is generally done explicitly in `__init__`, but is done by hand for
votes before the request context is lost by the queuing.
request, context: Should be pylons.request & pylons.c respectively'

@classmethod
def get_context_data(self, request, context):

    data = {}
    if context.user_is_loggedin:
        data['user_id'] = context.user._id
        data['user_name'] = context.user.name
    elif context.loid:
        data.update(context.loid.to_dict())
    oauth2_client = getattr(context, 'oauth2_client', None)
    if oauth2_client:
        data['oauth2_client_id'] = oauth2_client._id
        data['oauth2_client_name'] = oauth2_client.name
        data['oauth2_client_app_type'] = oauth2_client.app_type
    data['geoip_country'] = get_request_location(request, context)
    data['domain'] = request.host
    data['user_agent'] = request.user_agent
    data['user_agent_parsed'] = request.parsed_agent.to_dict()
    http_referrer = request.headers.get('Referer', None)
    if http_referrer:
        data['referrer_url'] = http_referrer
        data['referrer_domain'] = domain(http_referrer)
    hooks.get_hook('eventcollector.context_data').call(data=data, user=context.user, request=request, context=context)
    return data
