def get_route_name(request):
    """ Get a route name from URL Dispatch or Traversal """
    if request.matched_route:
        return request.matched_route.name.lower()
    else:
        try:
            ctx_class = request.context.__class__
        except AttributeError:
            return None
        ctx_name = ctx_class.__name__
        ctx_module = ctx_class.__module__.rsplit('.', 1)[-1]
        route_name = '%s_%s' % (ctx_module, ctx_name)
        return route_name.lower()
