def url_for(self, resource, **values):
        """Generates a URL to the given resource.

        Works like :func:`flask.url_for`."""
        endpoint = resource.endpoint
        if self.blueprint:
            endpoint = '{0}.{1}'.format(self.blueprint.name, endpoint)
        return url_for(endpoint, **values)