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


Python NoResource.render方法代码示例

本文整理汇总了Python中twisted.web.resource.NoResource.render方法的典型用法代码示例。如果您正苦于以下问题:Python NoResource.render方法的具体用法?Python NoResource.render怎么用?Python NoResource.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.web.resource.NoResource的用法示例。


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

示例1: render_POST

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
 def render_POST(self, request):
     if request.path != self._path:
         page = NoResource(
             message="API path %s is not supported" % request.URLPath())
         return page.render(request)
     if request.getHeader(b"Content-Type") != b"application/json":
         page = NoResource(
             message="Unsupported Content-Type (must be \"application/json"
                     "\")" % request.URLPath())
         return page.render(request)
     request.setHeader(b"Content-Type", b"application/json")
     self._callback(request)
     return NOT_DONE_YET
开发者ID:2php,项目名称:veles,代码行数:15,代码来源:restful_api.py

示例2: CgiDirectory

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
    class CgiDirectory(Resource, FilePath):

        cgiscript = CgiScript

        def __init__(self, pathname, filter, childNotFound=None):
            Resource.__init__(self)
            FilePath.__init__(self, pathname)
            self.filter = filter
            if childNotFound:
                self.childNotFound = childNotFound
            else:
                self.childNotFound = NoResource("CGI directories do not support directory listing.")

        def getChild(self, path, request):
            fnp = self.child(path)
            if not fnp.exists():
                return File.childNotFound
            elif fnp.isdir():
                return CgiDirectory(fnp.path, self.filter, self.childNotFound)
            else:
                return self.cgiscript(fnp.path, self.filter)
            return NoResource()

        def render(self, request):
            return self.childNotFound.render(request)
开发者ID:OspreyX,项目名称:crossbar,代码行数:27,代码来源:resource.py

示例3: render

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
 def render(self, request):
     if self.type == self.types.REDIRECT:
         return ""
     elif self.type == self.types.QUEUE:
         return NOT_DONE_YET
     else:
         return NoResource.render(self, request)
开发者ID:fullcounter,项目名称:txoffer,代码行数:9,代码来源:txoffer.py

示例4: return_404

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
    def return_404(self, request):
        """Return a 404 HTTP response.
        :param request: The request to which we are responding.
        :returns: NoResource's rendering of the request.

        Performed if a request tries to access a nonexistent table.
        """
        page = NoResource(message="Table %s could not be found" %
                          self.table_name)
        return page.render(request)
开发者ID:auntieNeo,项目名称:asterisk-testsuite,代码行数:12,代码来源:realtime_test_module.py

示例5: Server

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
	class Server(Resource):

		def __init__(self):
			Resource.__init__(self)
			self.isLeaf = True
			self.r404 = NoResource()

			fp = file(sys.argv[0])
			self.src = fp.read()
			fp.close()

			from subprocess import PIPE, Popen
			try:
				self.src_syn = Popen(['pandoc', '-s'], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate("~~~~ {.python}\n" + self.src + "~~~~\n")[0]
			except OSError:
				sys.stderr.write("pandoc not found; /src/ will default to plain text rather than syntax highlighted code\n")
				self.src_syn = None

		def render_GET(self, request):
			host, path = request.client.host, request.path
			print_flush_log("R %s %s" % (host, path))
			request.setHeader("content-type", "text/plain")

			if path == "/":
				return "%s %s\n%s\n/tcp/[port]\n/udp/[port]\n/src/\n/src/raw\n/src/get\n" % (NAME, VERSION, __doc__)

			try:
				type, port = path[1:].split('/', 2)

				if type == "src":
					if port == "raw":
						return self.src
					elif port == "get":
						request.setHeader("content-type", "text/x-python")
						request.setHeader("content-disposition", "attachment; filename=\"%s\"" % FNAME);
						return self.src
					elif self.src_syn is not None:
						request.setHeader("content-type", "text/html")
						return self.src_syn
					else:
						return self.src

				elif type not in PROTOCOL:
					raise KeyError

				port = int(port)

			except (ValueError, KeyError):
				return self.r404.render(request)

			else:
				start_connect(host, type, port, reactor.callLater)
				return "awaiting connection to %s %s %s" % (host, type, port)
开发者ID:infinity0,项目名称:l33tutils,代码行数:55,代码来源:conntest.py

示例6: render_DELETE

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
    def render_DELETE(self, request):
        # print "KeyResource.render_DELETE"
        if not self.isRemovable():
            epage = NoResource(
                "deleting collection %s failed." % request.uri)
            return epage.render(request)
            
        if self.isdir():
            depth = get_depth(request)
            if not depth:
                epage = BadRequestResource(
                    "deleting collection %s failed."
                    "because depth is not "infinity""
                    % request.uri)
                return epage.render(request)

            self.rmtree()
        else:
            self.remove()

        epage = NoContentResource("%s deleted" % request.uri)
        return epage.render(request)
开发者ID:steder,项目名称:AkaDAV,代码行数:24,代码来源:davresource.py

示例7: render

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
 def render(self, request):
    notFound = NoResource("CGI directories do not support directory listing.")
    return notFound.render(request)
开发者ID:Inspire2Innovate,项目名称:crossbar,代码行数:5,代码来源:cgiresource.py

示例8: responseNotFound

# 需要导入模块: from twisted.web.resource import NoResource [as 别名]
# 或者: from twisted.web.resource.NoResource import render [as 别名]
 def responseNotFound(self, request, failure):
     errorPage = NoResource(message=failure.getErrorMessage())
     request.write(errorPage.render(request))
     request.finish()
开发者ID:dir01,项目名称:lrcs,代码行数:6,代码来源:site.py


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