示例#1
0
 def renderHTTP(self, ctx):
     inevow.IRequest(ctx).setResponseCode(404)
     # Look for an application-remembered handler
     try:
         notFoundHandler = ctx.locate(inevow.ICanHandleNotFound)
     except KeyError as e:
         return self.notFound
     # Call the application-remembered handler but if there are any errors
     # then log it and fallback to the standard message.
     try:
         return notFoundHandler.renderHTTP_notFound(PageContext(parent=ctx, tag=notFoundHandler))
     except:
         log.err()
         return self.notFound
示例#2
0
文件: rend.py 项目: msdemlei/nevow
 def renderHTTP(self, ctx):
     inevow.IRequest(ctx).setResponseCode(404)
     # Look for an application-remembered handler
     try:
         notFoundHandler = ctx.locate(inevow.ICanHandleNotFound)
     except KeyError as e:
         return self.notFound
     # Call the application-remembered handler but if there are any errors
     # then log it and fallback to the standard message.
     try:
         return notFoundHandler.renderHTTP_notFound(
             PageContext(parent=ctx, tag=notFoundHandler))
     except:
         log.err()
         return self.notFound
示例#3
0
class FourOhFour:
    """A simple 404 (not found) page.
    """
    implements(inevow.IResource)

    notFound = "<html><head><title>Page Not Found</title></head><body>Sorry, but I couldn't find the object you requested.</body></html>"
    original = None

    def locateChild(self, ctx, segments):
        return NotFound

    def renderHTTP(self, ctx):
        inevow.IRequest(ctx).setResponseCode(404)
        # Look for an application-remembered handler
        try:
            notFoundHandler = ctx.locate(inevow.ICanHandleNotFound)
        except KeyError, e:
            return self.notFound
        # Call the application-remembered handler but if there are any errors
        # then log it and fallback to the standard message.
        try:
            return notFoundHandler.renderHTTP_notFound(
                PageContext(parent=ctx, tag=notFoundHandler))
        except:
            log.err()
            return self.notFound
示例#4
0
class FourOhFour:
    """A simple 404 (not found) page.
    """
    __implements__ = inevow.IResource,

    notFound = "<html><head><title>Page Not Found</title><head><body>Sorry, but I couldn't find the object you requested.</body></html>"
    original = None

    def locateChild(self, ctx, segments):
        return NotFound

    def renderHTTP(self, ctx):
        from twisted.protocols import http
        inevow.IRequest(ctx).setResponseCode(404)
        try:
            notFoundHandler = ctx.locate(inevow.ICanHandleNotFound)
            return notFoundHandler.renderHTTP_notFound(PageContext(parent=ctx, tag=notFoundHandler))
        except KeyError, e:
            return self.notFound
        except:
            log.err()
            return self.notFound

    def __nonzero__(self):
        return False


# Not found singleton
NotFound = None, ()
示例#5
0
class FourOhFour:
    """A simple 404 (not found) page.
    """
    __implements__ = inevow.IResource,

    notFound = "<html><head><title>Page Not Found</title><head><body>Sorry, but I couldn't find the object you requested.</body></html>"
    original = None

    def locateChild(self, ctx, segments):
        return NotFound

    def renderHTTP(self, ctx):
        from twisted.protocols import http
        inevow.IRequest(ctx).setResponseCode(404)
        try:
            notFoundHandler = ctx.locate(inevow.ICanHandleNotFound)
            return notFoundHandler.renderHTTP_notFound(
                PageContext(parent=ctx, tag=notFoundHandler))
        except KeyError, e:
            return self.notFound
        except:
            log.err()
            return self.notFound

    def __nonzero__(self):
        return False


# Not found singleton
NotFound = None, ()