def add_url_rules(bp, cls, decorator=None, decorator_args=[]):
    """
    add url rules to bp for class cls

    cls may define the following class attribute
        url_rules   dict {endpoint: options, ...} 
            endpoint    the endpoint for the registered URL rule
            options     tuple (url_rule[, methods[, defaults]])
                url_rule    the URL rule as string
                methods     tuple of supported methods, e.g. 'GET', 'POST'
                defaults    optional dict with defaults for other rules with the same endpoint
                            see http://werkzeug.pocoo.org/docs/0.14/routing/#werkzeug.routing.Rule
    """
    for endpoint, options in cls.url_rules.items():
        url_rule = options
        methods = 'GET',
        defaults = {}
        if len(options) == 2:
            url_rule, methods = options
        elif len(options) == 3:
            url_rule, methods, defaults = options
        if not decorator:
            view_func = cls.as_view(endpoint)
        else:
            view_func = decorator(*decorator_args)(cls.as_view(endpoint))
        bp.add_url_rule(url_rule, endpoint=endpoint, methods=methods,
            defaults=defaults, view_func=view_func)
