Example #1
0
    def test_marker_substitution(self):
        import re

        @http_handler("#{0}#".format(OBJID_PLACEHOLDER))
        class A(ExhibitionistRequestHandler):
            pass

        self.assertTrue(OBJID_REGEX_GROUP_NAME in re.compile(http_handler.get_route(A)).groupindex)
        self.assertTrue(http_handler.is_decorated_as_http(A))
Example #2
0
    def _register_handlers(self):
        """ register http_handlers with tornado application"""
        from tornado.web import URLSpec,Application

        urlconf = [URLSpec(http_handler.get_route(h), h,
                           name=http_handler.get_view_name(h),
                           kwargs=http_handler.get_kwds(h))
                   for h in self.http_handlers]

        self.application = Application(urlconf,
                                       **self.tornado_app_settings)
Example #3
0
    def subscribe(self, h):
        if self.isAlive():
            raise RuntimeError(
                "Registering http handlers after server start is not allowed")

        # exst_names=[x for x in self.http_handlers
        #             if  get_view_name(x) == get_view_name(h)]
        # if exst_names and exst_names[0] != h:
        if h in self.http_handlers:
            raise RuntimeError("view_name collision, "
                               "there's already a handler called %s" %
                               http_handler.get_view_name(h))

        if h not in self.http_handlers:
            tmpl = "Discovered {type} handler '{name}'  tagged with {route}"
            logger.debug(tmpl.format(type='http',
                                     name=http_handler.get_view_name(h),
                                     route=http_handler.get_route(h)))
            self.http_handlers.add(h)