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


Python util.ObjectDict方法代码示例

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


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

示例1: test_error_line_number_module

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def test_error_line_number_module(self):
        loader = None  # type: typing.Optional[DictLoader]

        def load_generate(path, **kwargs):
            assert loader is not None
            return loader.load(path).generate(**kwargs)

        loader = DictLoader(
            {"base.html": "{% module Template('sub.html') %}", "sub.html": "{{1/0}}"},
            namespace={"_tt_modules": ObjectDict(Template=load_generate)},
        )
        try:
            loader.load("base.html").generate()
            self.fail("did not get expected exception")
        except ZeroDivisionError:
            exc_stack = traceback.format_exc()
            self.assertTrue("# base.html:1" in exc_stack)
            self.assertTrue("# sub.html:1" in exc_stack) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:20,代码来源:template_test.py

示例2: test_error_line_number_module

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def test_error_line_number_module(self):
        loader = None

        def load_generate(path, **kwargs):
            return loader.load(path).generate(**kwargs)

        loader = DictLoader({
            "base.html": "{% module Template('sub.html') %}",
            "sub.html": "{{1/0}}",
        }, namespace={"_tt_modules": ObjectDict(Template=load_generate)})
        try:
            loader.load("base.html").generate()
            self.fail("did not get expected exception")
        except ZeroDivisionError:
            exc_stack = traceback.format_exc()
            self.assertTrue('# base.html:1' in exc_stack)
            self.assertTrue('# sub.html:1' in exc_stack) 
开发者ID:tp4a,项目名称:teleport,代码行数:19,代码来源:template_test.py

示例3: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def __init__(self, app, handler, store, initializer, session_config=None, session_object=None):
        self.handler = handler
        self.app = app
        self.store = store or DiskStore(app_config.store_config.diskpath)

        self._config = deepcopy(app_config.session_config)
        if session_config:
            self._config.update(session_config)

        self._session_name = self._config.name

        self._session_object = (session_object or CookieObject)(
            app, handler, self.store, self._config)

        self._data = ObjectDict()
        self._initializer = initializer

        self.session_id = None

        self._dirty = False
        self._processor() 
开发者ID:wecatch,项目名称:app-turbo,代码行数:23,代码来源:session.py

示例4: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def __init__(self, application, request, **kwargs):
        self.application = application
        self.request = request
        self._headers_written = False
        self._finished = False
        self._auto_finish = True
        self._transforms = None  # will be set in _execute
        self.ui = ObjectDict((n, self._ui_method(m)) for n, m in
                     application.ui_methods.iteritems())
        # UIModules are available as both `modules` and `_modules` in the
        # template namespace.  Historically only `modules` was available
        # but could be clobbered by user additions to the namespace.
        # The template {% module %} directive looks in `_modules` to avoid
        # possible conflicts.
        self.ui["_modules"] = ObjectDict((n, self._ui_module(n, m)) for n, m in
                                 application.ui_modules.iteritems())
        self.ui["modules"] = self.ui["_modules"]
        self.clear()
        # Check since connection is not available in WSGI
        if getattr(self.request, "connection", None):
            self.request.connection.stream.set_close_callback(
                self.on_connection_close)
        self.initialize(**kwargs) 
开发者ID:omererdem,项目名称:honeything,代码行数:25,代码来源:web.py

示例5: clean_lg_company_data

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def clean_lg_company_data(company_dict):
    """
    清洗爬取到的公司信息

    :param company_dict: tornado.util.ObjectDict
    """
    if 'size' in company_dict:
        company_dict.size = company_dict.size.strip()
    if 'finance_stage' in company_dict:
        company_dict.finance_stage = company_dict.finance_stage.strip()
    if 'features' in company_dict:
        company_dict.features = utils.text.to_plaintext(company_dict.features)
    if 'address' in company_dict:
        company_dict.address = utils.text.to_plaintext(company_dict.address)
    if 'introduce' in company_dict:
        company_dict.introduce = ''.join(company_dict.introduce) if company_dict.introduce else ''
        company_dict.introduce = company_dict.introduce[:constants.COMPANY_INTRODUCE_MAX_LEN]
    if 'advantage' in company_dict:
        company_dict.advantage = list(map(utils.text.to_plaintext, company_dict.advantage))
        company_dict.advantage = json.dumps(company_dict.advantage)[
            :constants.COMPANY_ADVANTAGE_MAX_LEN]
    if 'industries' in company_dict:
        company_dict.industries = set(re.split(r",|,|、|\s", company_dict.industries)) 
开发者ID:JustForFunnnn,项目名称:webspider,代码行数:25,代码来源:lagou_companies.py

示例6: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def __init__(self, conn, http2_params, server):
        self.conn = conn
        self.context = conn.context
        self.http2_params = http2_params
        self.server = server
        self.upgrading = False
        self.written_headers = None
        self.written_chunks = []
        self.write_finished = False
        self.close_callback = None
        self.max_body_size = None
        self.body_timeout = None

        # TODO: remove
        from tornado.util import ObjectDict
        self.stream = ObjectDict(io_loop=IOLoop.current(), close=conn.stream.close) 
开发者ID:bdarnell,项目名称:tornado_http2,代码行数:18,代码来源:server.py

示例7: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def __init__(self, conn, stream_id, delegate, context=None):
        self.conn = conn
        self.stream_id = stream_id
        self.set_delegate(delegate)
        self.context = context
        self.finish_future = Future()
        self.write_lock = Lock()
        from tornado.util import ObjectDict
        # TODO: remove
        self.stream = ObjectDict(io_loop=IOLoop.current(), close=conn.stream.close)
        self._incoming_content_remaining = None
        self._outgoing_content_remaining = None
        self._delegate_started = False
        self.window = Window(conn.window, stream_id,
                             conn.setting(constants.Setting.INITIAL_WINDOW_SIZE))
        self._header_frames = []
        self._phase = constants.HTTPPhase.HEADERS 
开发者ID:bdarnell,项目名称:tornado_http2,代码行数:19,代码来源:stream.py

示例8: on_message

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def on_message(self, message):
        """Handshake with livereload.js

        1. client send 'hello'
        2. server reply 'hello'
        3. client send 'info'
        """
        message = ObjectDict(escape.json_decode(message))
        if message.command == 'hello':
            handshake = {
                'command': 'hello',
                'protocols': [
                    'http://livereload.com/protocols/official-7',
                ],
                'serverName': 'livereload-tornado',
            }
            self.send_message(handshake)

        if message.command == 'info' and 'url' in message:
            logger.info('Browser Connected: %s' % message.url)
            LiveReloadHandler.waiters.add(self) 
开发者ID:tjwalch,项目名称:django-livereload-server,代码行数:23,代码来源:handlers.py

示例9: generate

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def generate(self, **kwargs):
        """用给定参数生成此模板."""
        namespace = {
            "escape": escape.xhtml_escape,
            "xhtml_escape": escape.xhtml_escape,
            "url_escape": escape.url_escape,
            "json_encode": escape.json_encode,
            "squeeze": escape.squeeze,
            "linkify": escape.linkify,
            "datetime": datetime,
            "_tt_utf8": escape.utf8,  # for internal use
            "_tt_string_types": (unicode_type, bytes),
            # __name__ and __loader__ allow the traceback mechanism to find
            # the generated source code.
            "__name__": self.name.replace('.', '_'),
            "__loader__": ObjectDict(get_source=lambda name: self.code),
        }
        namespace.update(self.namespace)
        namespace.update(kwargs)
        exec_in(self.compiled, namespace)
        execute = namespace["_tt_execute"]
        # Clear the traceback module's cache of source data now that
        # we've generated a new template (mainly for this module's
        # unittests, where different tests reuse the same name).
        linecache.clearcache()
        return execute() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:28,代码来源:template.py

示例10: test_error_line_number_module

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def test_error_line_number_module(self):
        loader = DictLoader({
            "base.html": "{% module Template('sub.html') %}",
            "sub.html": "{{1/0}}",
        }, namespace={"_tt_modules": ObjectDict({"Template": lambda path, **kwargs: loader.load(path).generate(**kwargs)})})
        try:
            loader.load("base.html").generate()
            self.fail("did not get expected exception")
        except ZeroDivisionError:
            exc_stack = traceback.format_exc()
            self.assertTrue('# base.html:1' in exc_stack)
            self.assertTrue('# sub.html:1' in exc_stack) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:14,代码来源:template_test.py

示例11: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def __init__(self, cookie_secret='0123456789', key_version=None):
        # don't call super.__init__
        self._cookies = {}
        if key_version is None:
            self.application = ObjectDict(settings=dict(cookie_secret=cookie_secret))
        else:
            self.application = ObjectDict(settings=dict(cookie_secret=cookie_secret,
                                                        key_version=key_version)) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:10,代码来源:web_test.py

示例12: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def __init__(
        self,
        application: "Application",
        request: httputil.HTTPServerRequest,
        **kwargs: Any
    ) -> None:
        super(RequestHandler, self).__init__()

        self.application = application
        self.request = request
        self._headers_written = False
        self._finished = False
        self._auto_finish = True
        self._prepared_future = None
        self.ui = ObjectDict(
            (n, self._ui_method(m)) for n, m in application.ui_methods.items()
        )
        # UIModules are available as both `modules` and `_tt_modules` in the
        # template namespace.  Historically only `modules` was available
        # but could be clobbered by user additions to the namespace.
        # The template {% module %} directive looks in `_tt_modules` to avoid
        # possible conflicts.
        self.ui["_tt_modules"] = _UIModuleNamespace(self, application.ui_modules)
        self.ui["modules"] = self.ui["_tt_modules"]
        self.clear()
        assert self.request.connection is not None
        # TODO: need to add set_close_callback to HTTPConnection interface
        self.request.connection.set_close_callback(  # type: ignore
            self.on_connection_close
        )
        self.initialize(**kwargs)  # type: ignore 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:33,代码来源:web.py

示例13: generate

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def generate(self, **kwargs: Any) -> bytes:
        """Generate this template with the given arguments."""
        namespace = {
            "escape": escape.xhtml_escape,
            "xhtml_escape": escape.xhtml_escape,
            "url_escape": escape.url_escape,
            "json_encode": escape.json_encode,
            "squeeze": escape.squeeze,
            "linkify": escape.linkify,
            "datetime": datetime,
            "_tt_utf8": escape.utf8,  # for internal use
            "_tt_string_types": (unicode_type, bytes),
            # __name__ and __loader__ allow the traceback mechanism to find
            # the generated source code.
            "__name__": self.name.replace(".", "_"),
            "__loader__": ObjectDict(get_source=lambda name: self.code),
        }
        namespace.update(self.namespace)
        namespace.update(kwargs)
        exec_in(self.compiled, namespace)
        execute = typing.cast(Callable[[], bytes], namespace["_tt_execute"])
        # Clear the traceback module's cache of source data now that
        # we've generated a new template (mainly for this module's
        # unittests, where different tests reuse the same name).
        linecache.clearcache()
        return execute() 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:28,代码来源:template.py

示例14: __init__

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def __init__(self, cookie_secret="0123456789", key_version=None):
        # don't call super.__init__
        self._cookies = {}  # type: typing.Dict[str, bytes]
        if key_version is None:
            self.application = ObjectDict(settings=dict(cookie_secret=cookie_secret))
        else:
            self.application = ObjectDict(
                settings=dict(cookie_secret=cookie_secret, key_version=key_version)
            ) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:11,代码来源:web_test.py

示例15: data

# 需要导入模块: from tornado import util [as 别名]
# 或者: from tornado.util import ObjectDict [as 别名]
def data(cls):
            if not hasattr(cls._state, 'data'):
               return ObjectDict({})
            return ObjectDict(cls._state.data) 
开发者ID:mqingyn,项目名称:torngas,代码行数:6,代码来源:utils.py


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