# -*- coding: UTF-8 -*-
from conference import cachef
from conference import dataaccess as cdata
from conference import models as cmodels
from assopy import models as amodels
from assopy import utils as autils
from p3 import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType

cache_me = cachef.CacheFunction(prefix='p3:')

def profile_data(uid, preload=None):
    if preload is None:
        preload = {}
    profile = cdata.profile_data(uid)
    try:
        p3p = preload['profile']
    except KeyError:
        try:
            p3p = models.P3Profile.objects\
                .select_related('profile__user')\
                .get(profile=uid)
        except models.P3Profile.DoesNotExist:
            p3p = None
    if p3p:
        try: