'Creates a URL adapter for the given request.  The URL adapter
is created at a point where the request context is not yet set up
so the request is passed explicitly.
.. versionadded:: 0.6
.. versionchanged:: 0.9
This can now also be called without a request object when the
URL adapter is created for the application context.'

def create_url_adapter(self, request):

    if (request is not None):
        return self.url_map.bind_to_environ(request.environ, server_name=self.config['SERVER_NAME'])
    if (self.config['SERVER_NAME'] is not None):
        return self.url_map.bind(self.config['SERVER_NAME'], script_name=self.config['APPLICATION_ROOT'], url_scheme=self.config['PREFERRED_URL_SCHEME'])
