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


Python asyncio.html方法代码示例

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


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

示例1: check_origin

# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import html [as 别名]
def check_origin(self, origin):
        """ Handle cross-domain access; override default same origin policy.
        """
        # http://www.tornadoweb.org/en/stable/_modules/tornado/websocket.html
        #WebSocketHandler.check_origin

        serving_host = self.request.headers.get("Host")
        serving_hostname, _, serving_port = serving_host.partition(':')
        connecting_host = urlparse(origin).netloc
        connecting_hostname, _, connecting_port = connecting_host.partition(':')

        serving_port = serving_port or '80'
        connecting_port = connecting_port or '80'

        if serving_hostname == 'localhost':
            return True  # Safe
        elif serving_host == connecting_host:
            return True  # Passed most strict test, hooray!
        elif serving_hostname == '0.0.0.0' and serving_port == connecting_port:
            return True  # host on all addressses; best we can do is check port
        elif connecting_host in config.host_whitelist:
            return True
        else:
            logger.warning('Connection refused from %s' % origin)
            return False 
开发者ID:flexxui,项目名称:flexx,代码行数:27,代码来源:_tornadoserver.py

示例2: delete_object

# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import html [as 别名]
def delete_object(obj, recursive=False, delete_nullable=False):
    """Delete object asynchronously.

    :param obj: object to delete
    :param recursive: if ``True`` also delete all other objects depends on
        object
    :param delete_nullable: if `True` and delete is recursive then delete even
        'nullable' dependencies

    For details please check out `Model.delete_instance()`_ in peewee docs.

    .. _Model.delete_instance(): http://peewee.readthedocs.io/en/latest/peewee/
        api.html#Model.delete_instance
    """
    warnings.warn("delete_object() is deprecated, Manager.delete() "
                  "should be used instead",
                  DeprecationWarning)

    # Here are private calls involved:
    # - obj._pk_expr()
    if recursive:
        dependencies = obj.dependencies(delete_nullable)
        for query, fk in reversed(list(dependencies)):
            model = fk.model
            if fk.null and not delete_nullable:
                await update(model.update(**{fk.name: None}).where(query))
            else:
                await delete(model.delete().where(query))
    result = await delete(obj.delete().where(obj._pk_expr()))
    return result 
开发者ID:05bit,项目名称:peewee-async,代码行数:32,代码来源:peewee_async.py

示例3: update_object

# 需要导入模块: import asyncio [as 别名]
# 或者: from asyncio import html [as 别名]
def update_object(obj, only=None):
    """Update object asynchronously.

    :param obj: object to update
    :param only: list or tuple of fields to updata, is `None` then all fields
        updated

    This function does the same as `Model.save()`_ for already saved object,
        but it doesn't invoke ``save()`` method on model class. That is
        important to know if you overrided save method for your model.

    .. _Model.save(): http://peewee.readthedocs.io/en/latest/peewee/
        api.html#Model.save
    """
    # Here are private calls involved:
    #
    # - obj._data
    # - obj._meta
    # - obj._prune_fields()
    # - obj._pk_expr()
    # - obj._dirty.clear()
    #
    warnings.warn("update_object() is deprecated, Manager.update() "
                  "should be used instead",
                  DeprecationWarning)

    field_dict = dict(obj.__data__)
    pk_field = obj._meta.primary_key

    if only:
        field_dict = obj._prune_fields(field_dict, only)

    if not isinstance(pk_field, peewee.CompositeKey):
        field_dict.pop(pk_field.name, None)
    else:
        field_dict = obj._prune_fields(field_dict, obj.dirty_fields)
    rows = await update(obj.update(**field_dict).where(obj._pk_expr()))

    obj._dirty.clear()
    return rows 
开发者ID:05bit,项目名称:peewee-async,代码行数:42,代码来源:peewee_async.py


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