Clean up describe_func stack inspection

Separate out the stack-inspecting sketchiness into another function,
get_containing_class. Use this inside @cache_function to get the
enclosing class, but allow it to be overridden when called from other
decorators such as @cache_inclusion_tag and @cached_module_view.