当前位置: 首页>>代码示例>>Python>>正文


Python urlpath.URLPath类代码示例

本文整理汇总了Python中twisted.python.urlpath.URLPath的典型用法代码示例。如果您正苦于以下问题:Python URLPath类的具体用法?Python URLPath怎么用?Python URLPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了URLPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: links

 def links(self, request, tag):
     ds = self.root.edits(self.ob)
     therange = range(len(ds))
     rev = therange[self.rev]
     ul = tags.ul()
     for i in therange:
         li = tags.li()
         if i:
             u = URLPath.fromRequest(request)
             u = u.sibling('diff')
             u.query = urllib.urlencode({
                 'ob': self.ob.fullName(),
                 'revA': i-1,
                 'revB': i,
                 })
             li(tags.a(href=str(u))("(diff)"))
         else:
             li("(diff)")
         li(" - ")
         if i == len(ds) - 1:
             label = "Latest"
         else:
             label = str(i)
         if i == rev:
             li(label)
         else:
             u = URLPath.fromRequest(request)
             u.query = urllib.urlencode({
                 'rev': str(i),
                 'ob': self.ob.fullName(),
                 })
             li(tags.a(href=str(u))(label))
         li(' - ' + ds[i].user + '/' + ds[i].time)
         ul(li)
     return tag(ul)
开发者ID:chevah,项目名称:pydoctor,代码行数:35,代码来源:server.py

示例2: uri_for_service

    def uri_for_service(self, region, service_id, base_uri):
        """
        Generate a URI prefix for a given region and service ID.

        Each plugin loaded into mimic generates a list of catalog entries; each
        catalog entry has a list of endpoints.  Each endpoint has a URI
        associated with it, which we call a "URI prefix", because the endpoint
        will have numerous other URIs beneath it in the hierarchy, generally
        starting with a version number and tenant ID.  The URI prefixes
        generated for this function point to the top of the endpoint's
        hierarchy, not including any tenant information.

        :param unicode region: the name of the region that the service resource
            exists within.
        :param unicode service_id: the UUID for the service for the specified
            region
        :param str base_uri: the base uri to use instead of the default - most
            likely comes from a request URI

        :return: The full URI locating the service for that region
        :rtype: ``str``
        """
        if region:
            return str(URLPath.fromString(base_uri)
                    .child("mimicking").child(service_id).child(region).child(""))
        else:
            return str(URLPath.fromString(base_uri)
                    .child("mimicking").child(service_id).child(""))
开发者ID:obulpathi,项目名称:mimic,代码行数:28,代码来源:core.py

示例3: makeURLPath

def makeURLPath(s):
    """
    Create a URLPath with the given text or bytes.
    """
    if hasattr(URLPath, 'fromBytes') and isinstance(s, bytes):
        return URLPath.fromBytes(s)
    else:
        return URLPath.fromString(s)
开发者ID:BenjamenMeyer,项目名称:mimic,代码行数:8,代码来源:helpers.py

示例4: url

 def url(self, suffix):
     """
     Generate a URL to an object within the Heat URL hierarchy, given the
     part of the URL that comes after.
     """
     return str(URLPath.fromString(self.uri_prefix)
                .child(suffix.encode("utf-8")))
开发者ID:derwolfe,项目名称:mimic,代码行数:7,代码来源:heat_api.py

示例5: initialize

    def initialize(self):
        self.clean()

        def resolveCb(result):
            self.mangle.createChain(chain="cattivo")

            entry = self._createAuthenticatorEntry(result)
            self.mangle.appendEntry(entry, chain="cattivo")

            entry = self._createLocalTrafficEntry()
            self.mangle.appendEntry(entry, chain="cattivo")

            entry = self._createDefaultTproxyEntry()
            self.mangle.appendEntry(entry, chain="cattivo")
            self.mangle.commit()

            entry = self._createJumpInCattivoEntry()
            self.mangle.appendEntry(entry, chain="PREROUTING")
            self.mangle.commit()

        authenticator = cattivo.config.get("authenticator", "host")
        url = URLPath.fromString(authenticator)
        address = url.netloc
        dfr = reactor.resolve(address)
        dfr.addCallback(resolveCb)

        return dfr
开发者ID:alessandrod,项目名称:cattivo,代码行数:27,代码来源:base.py

示例6: hist

 def hist(self, data, request):
     u = URLPath.fromRequest(request)
     u = u.sibling('diff')
     u.query = urllib.urlencode({
         'ob': data.obj.fullName(),
         'rev': data.rev,
         })
     return tags.a(href=str(u))("(hist)")
开发者ID:chevah,项目名称:pydoctor,代码行数:8,代码来源:server.py

示例7: __init__

 def __init__(self, mapsPath, fetchURL, deleteIfNotPresent, tfLevelSounds,
         listURL, keyPrefix):
     MapUpdater.__init__(self, mapsPath, fetchURL, deleteIfNotPresent,
                         tfLevelSounds)
     assert isinstance(listURL, str) and len(listURL)
     assert isinstance(keyPrefix, str) and len(keyPrefix)
     self.listURL = URLPath.fromString(listURL)
     self.keyPrefix = keyPrefix
开发者ID:jsza,项目名称:tempus-map-updater,代码行数:8,代码来源:updater.py

示例8: request

def request(testCase, rootResource, method, uri, body=b"", baseURI="http://localhost:8900/"):
    """
    Issue a request and return a synchronous response.
    """
    # allow for relative or absolute URIs, since we're going to the same
    # resource no matter what
    return RequestTraversalAgent(testCase, rootResource).request(
        method, str(URLPath.fromString(baseURI).click(uri)), bodyProducer=SynchronousProducer(body)
    )
开发者ID:kivattik,项目名称:mimic,代码行数:9,代码来源:helpers.py

示例9: base_uri_from_request

def base_uri_from_request(request):
    """
    Given a request, return the base URI of the request

    :param request: a twisted HTTP request
    :type request: :class:`twisted.web.http.Request`

    :return: the base uri the request was trying to access
    :rtype: ``str``
    """
    return str(URLPath.fromRequest(request).click(b'/'))
开发者ID:pratikmallya,项目名称:mimic,代码行数:11,代码来源:identity_api.py

示例10: _toUrl

 def _toUrl(spec):
     if not spec:
         raise cli.UsageError("No Pub server")
     from twisted.python.urlpath import URLPath
     try:
         url = URLPath.fromString(spec)
     except:
         raise cli.UsageError("Invalid URL: {0}".format(spec))
     if not spec.startswith(url.scheme):
         raise cli.UsageError("Invalid URL: {0}".format(spec))
     return url
开发者ID:olix0r,项目名称:pub,代码行数:11,代码来源:cli.py

示例11: __init__

    def __init__(self, uri, agent=None):
        """
        @type  uri: L{unicode}
        @param uri: Entropy endpoint URI, for example:
            C{http://example.com/entropy/}.

        @type  agent: L{twisted.web.iweb.IAgent}
        @param agent: Twisted Web agent.
        """
        self.uri = URLPath.fromString(uri)
        if agent is None:
            agent = Agent(reactor)
        self._agent = agent
开发者ID:fusionapp,项目名称:entropy,代码行数:13,代码来源:client.py

示例12: __init__

 def __init__(self, uri, verify, timeout=600, reactor=reactor, clientCert=None):
     Resource.__init__(self)
     self._uri = URLPath.fromString(uri)
     self._verify = verify
     self._timeout = timeout
     self._reactor = reactor
     pool = HTTPConnectionPool(reactor)
     if clientCert is not None:
         clientCert = PrivateCertificate.loadPEM(
             FilePath(clientCert).getContent())
     self._agent = Agent(
         reactor,
         StupidPolicyForHTTPS(InsecureTLSOptions(clientCert)),
         pool=pool)
开发者ID:fusionapp,项目名称:soapproxy,代码行数:14,代码来源:proxy.py

示例13: uri_for_service

    def uri_for_service(self, region, service_id, base_uri):
        """
        Generate a URI prefix for a given region and service ID.

        :param unicode region_name: the name of the region that the service
            resource exists within.
        :param unicode service_id: the UUID for the service for the
            specified region
        :param str base_uri: the base uri to use instead of the default -
            most likely comes from a request URI

        :return: The full URI locating the service for that region
        """
        return str(URLPath.fromString(base_uri)
                   .child("service").child(region).child(service_id).child(""))
开发者ID:jirwin,项目名称:mimic,代码行数:15,代码来源:core.py

示例14: handleProcess

    def handleProcess(self, request):
        path = URLPath.fromBytes(getUrlForRequest(request))
        args = {k: v[0] for k, v in request.args.iteritems()}
        oidconsumer = self.getConsumer(request)

        def _cb(info):
            if info.status == consumer.FAILURE:
                request.setResponseCode(http.UNAUTHORIZED)
                return Data('Login failed', 'text/plain')

            ident = info.getDisplayIdentifier()
            return self.loginCallback(request, ident)

        d = self.semaphore.run(oidconsumer.complete, args, str(path))
        d.addCallback(_cb)
        return DeferredResource(d)
开发者ID:jsza,项目名称:jump-map-list,代码行数:16,代码来源:guard.py

示例15: absoluteURL

def absoluteURL(request, ob):
    if ob.documentation_location == model.DocLocation.PARENT_PAGE:
        p = ob.parent
        if isinstance(p, model.Module) and p.name == '__init__':
            p = p.parent
        child = p.fullName() + '.html'
        frag = ob.name
    elif ob.documentation_location == model.DocLocation.OWN_PAGE:
        child = ob.fullName() + '.html'
        frag = None
    else:
        raise AssertionError("XXX")
    u = URLPath.fromRequest(request)
    u = u.sibling(child)
    u.query = ''
    u.fragment = frag
    return str(u)
开发者ID:chevah,项目名称:pydoctor,代码行数:17,代码来源:server.py


注:本文中的twisted.python.urlpath.URLPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。