'Performs resolution of a real variable (i.e. not a literal) against the
given context.
As indicated by the method\'s name, this method is an implementation
detail and shouldn\'t be called by external code. Use Variable.resolve()
instead.'

def _resolve_lookup(self, context):

    current = context
    try:
        for bit in self.lookups:
            try:
                current = current[bit]
            except (TypeError, AttributeError, KeyError, ValueError):
                try:
                    if (isinstance(current, BaseContext) and getattr(type(current), bit)):
                        raise AttributeError
                    current = getattr(current, bit)
                except (TypeError, AttributeError):
                    try:
                        current = current[int(bit)]
                    except (IndexError, ValueError, KeyError, TypeError):
                        raise VariableDoesNotExist(u'Failed    lookup    for    key    [%s]    in    %r', (bit, current))
            if callable(current):
                if getattr(current, u'do_not_call_in_templates', False):
                    pass
                elif getattr(current, u'alters_data', False):
                    current = settings.TEMPLATE_STRING_IF_INVALID
                else:
                    try:
                        current = current()
                    except TypeError:
                        current = settings.TEMPLATE_STRING_IF_INVALID
    except Exception as e:
        if getattr(e, u'silent_variable_failure', False):
            current = settings.TEMPLATE_STRING_IF_INVALID
        else:
            raise
    return current
