

def __get__(self, instance, instance_type=None):
    if (instance is None):
        return self
    try:
        rel_obj = getattr(instance, self.cache_name)
    except AttributeError:
        related_pk = instance._get_pk_val()
        if (related_pk is None):
            rel_obj = None
        else:
            params = {
                ('%s__pk' % self.related.field.name): related_pk,
            }
            try:
                rel_obj = self.get_query_set(instance=instance).get(**params)
            except self.related.model.DoesNotExist:
                rel_obj = None
            else:
                setattr(rel_obj, self.related.field.get_cache_name(), self)
        setattr(instance, self.cache_name, rel_obj)
    if (rel_obj is None):
        raise self.related.model.DoesNotExist
    else:
        return rel_obj

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/db/models/fields/related.py SingleRelatedObjectDescriptor.__get__/VarMisuse@153/200 `instance`->`self`