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


Python cherrypy.NotFound方法代码示例

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


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

示例1: handler

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def handler(self, *args, **kwargs):
        """Use this tool as a CherryPy page handler.

        For example::

            class Root:
                nav = tools.staticdir.handler(section="/nav", dir="nav",
                                              root=absDir)
        """
        @expose
        def handle_func(*a, **kw):
            handled = self.callable(*args, **self._merged_args(kwargs))
            if not handled:
                raise cherrypy.NotFound()
            return cherrypy.serving.response.body
        return handle_func 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:18,代码来源:_cptools.py

示例2: _attempt

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def _attempt(filename, content_types, debug=False):
    if debug:
        cherrypy.log('Attempting %r (content_types %r)' %
                     (filename, content_types), 'TOOLS.STATICDIR')
    try:
        # you can set the content types for a
        # complete directory per extension
        content_type = None
        if content_types:
            r, ext = os.path.splitext(filename)
            content_type = content_types.get(ext[1:], None)
        serve_file(filename, content_type=content_type, debug=debug)
        return True
    except cherrypy.NotFound:
        # If we didn't find the static file, continue handling the
        # request. We might find a dynamic handler instead.
        if debug:
            cherrypy.log('NotFound', 'TOOLS.STATICFILE')
        return False 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:21,代码来源:static.py

示例3: read

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def read(self, logicname=None):
        """
        return an object with type info about all logics
        """
        # create a list of dicts, where each dict contains the information for one logic
        self.logger.info("LogicsController.read()")

        if self.plugins is None:
            self.plugins = Plugins.get_instance()
        if self.scheduler is None:
            self.scheduler = Scheduler.get_instance()

        self.logics_initialize()
        if self.logics is None:
            # SmartHomeNG has not yet initialized the logics module (still starting up)
            raise cherrypy.NotFound

        if logicname is None:
            return self.get_logics_info()
        else:
            return self.get_logic_info(logicname) 
开发者ID:smarthomeNG,项目名称:smarthome,代码行数:23,代码来源:api_logics.py

示例4: read

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def read(self, id=None):
        """
        Handle GET requests
        """

        if self.items is None:
            self.items = Items.get_instance()

        if id == 'structs':
            # /api/items/structs
            self.logger.info("ItemsController.root(): item_name = {}".format(id))
            result = self.items.return_struct_definitions()

            return json.dumps(result)

            #raise cherrypy.NotFound
            #self.logger.info("LogController (GET): logfiles = {}".format(logs))
            #return json.dumps({'logs':logs, 'default': self.root_logname})

        return None 
开发者ID:smarthomeNG,项目名称:smarthome,代码行数:22,代码来源:api_items.py

示例5: handler

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def handler(self, *args, **kwargs):
        """Use this tool as a CherryPy page handler.

        For example::

            class Root:
                nav = tools.staticdir.handler(section="/nav", dir="nav",
                                              root=absDir)
        """
        def handle_func(*a, **kw):
            handled = self.callable(*args, **self._merged_args(kwargs))
            if not handled:
                raise cherrypy.NotFound()
            return cherrypy.serving.response.body
        handle_func.exposed = True
        return handle_func 
开发者ID:naparuba,项目名称:opsbro,代码行数:18,代码来源:_cptools.py

示例6: handler

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def handler(self, *args, **kwargs):
        """Use this tool as a CherryPy page handler.
        
        For example::
        
            class Root:
                nav = tools.staticdir.handler(section="/nav", dir="nav",
                                              root=absDir)
        """
        def handle_func(*a, **kw):
            handled = self.callable(*args, **self._merged_args(kwargs))
            if not handled:
                raise cherrypy.NotFound()
            return cherrypy.serving.response.body
        handle_func.exposed = True
        return handle_func 
开发者ID:binhex,项目名称:moviegrabber,代码行数:18,代码来源:_cptools.py

示例7: __call__

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def __call__(self, path_info):
        """Set handler and config for the current request."""
        request = cherrypy.serving.request
        func, vpath = self.find_handler(path_info)

        if func:
            # Decode any leftover %2F in the virtual_path atoms.
            vpath = [x.replace('%2F', '/') for x in vpath]
            request.handler = LateParamPageHandler(func, *vpath)
        else:
            request.handler = cherrypy.NotFound() 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:13,代码来源:_cpdispatch.py

示例8: REST_dispatch

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def REST_dispatch(self, root, resource, **params):
        # if this gets called, we assume that default has already
        # traversed down the tree to the right location and this is
        # being called for a raw resource
        method = cherrypy.request.method
        if method in self.REST_map:
            try:
                m = getattr(self,self.REST_map[method])
            except:
                self.logger.info("REST_dispatch *1: Unsupported method  = {} for resource '{}'".format(method, resource))
                raise cherrypy.HTTPError(status=404)
            result = self.REST_dispatch_execute(m, method, root, resource, **params)
            if result != None:
                return result
            else:
                raise cherrypy.NotFound
        else:
            if method in self.REST_defaults:
                try:
                    m = getattr(self,self.REST_defaults[method])
                except:
                    self.logger.info("REST_dispatch: Unsupported method  = {} for resource '{}'".format(method, resource))
                    raise cherrypy.HTTPError(status=404)
                result = self.REST_dispatch_execute(m, method, root, resource, **params)
                if result != None:
                    return result
                else:
                    raise cherrypy.NotFound

        raise cherrypy.NotFound 
开发者ID:smarthomeNG,项目名称:smarthome,代码行数:32,代码来源:rest.py

示例9: default

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def default(self, *vpath, **params):
        if not vpath:
            resource = None
            # self.logger.info("RESTResource.default: vpath = '{}',  params = '{}'".format(list(vpath), dict(**params)))

            return self.REST_dispatch(True, resource, **params)
            # return list(**params)
        # self.logger.info("RESTResource.default: vpath = '{}',  params = '{}'".format(list(vpath), dict(**params)))
        # Make a copy of vpath in a list
        vpath = list(vpath)
        atom = vpath.pop(0)

        # Coerce the ID to the correct db type
        resource = self.REST_instantiate(atom)
        if resource is None:
            if cherrypy.request.method == "PUT":
                # PUT is special since it can be used to create
                # a resource
                resource = self.REST_create(atom)
            else:
                raise cherrypy.NotFound

        # There may be further virtual path components.
        # Try to map them to methods in children or this class.
        if vpath:
            a = vpath.pop(0)
            if a in self.REST_children:
                c = self.REST_children[a]
                c.parent = resource
                return c.default(*vpath, **params)
            method = getattr(self, a, None)
            if method and getattr(method, "expose_resource"):
                return method(resource, *vpath, **params)
            else:
                # path component was specified but doesn't
                # map to anything exposed and callable
                raise cherrypy.NotFound

        # No further known vpath components. Call a default handler
        # based on the method
        return self.REST_dispatch(False, resource,**params) 
开发者ID:smarthomeNG,项目名称:smarthome,代码行数:43,代码来源:rest.py

示例10: __call__

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def __call__(self, path_info):
        """Set handler and config for the current request."""
        request = cherrypy.serving.request
        func, vpath = self.find_handler(path_info)

        if func:
            # Decode any leftover %2F in the virtual_path atoms.
            vpath = [x.replace("%2F", "/") for x in vpath]
            request.handler = LateParamPageHandler(func, *vpath)
        else:
            request.handler = cherrypy.NotFound() 
开发者ID:naparuba,项目名称:opsbro,代码行数:13,代码来源:_cpdispatch.py

示例11: __call__

# 需要导入模块: import cherrypy [as 别名]
# 或者: from cherrypy import NotFound [as 别名]
def __call__(self, path_info):
        """Set handler and config for the current request."""
        request = cherrypy.serving.request
        func, vpath = self.find_handler(path_info)
        
        if func:
            # Decode any leftover %2F in the virtual_path atoms.
            vpath = [x.replace("%2F", "/") for x in vpath]
            request.handler = LateParamPageHandler(func, *vpath)
        else:
            request.handler = cherrypy.NotFound() 
开发者ID:binhex,项目名称:moviegrabber,代码行数:13,代码来源:_cpdispatch.py


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