def get_controller(self, request):
    """
    Retrieves the controller instance that is currently set
    in the current environment (request) falling back
    to an invalid (unset)  value in case no controller was
    found for the current environment.

    :type request: Request
    :param request: The request that is going to be
    used to try to retrieve the controller.
    :rtype: Controller
    :return: The controller retrieved from the provided context,
    this value may be unset in case it was not possible to retrieve
    the controller from the current environment/context.
    """

    if not hasattr(request, "controller"): return None
    return getattr(request, "controller")