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


Python UserDict.DictMixin方法代码示例

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


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

示例1: view

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def view(tpl_name, **defaults):
    ''' Decorator: renders a template for a handler.
        The handler can control its behavior like that:

          - return a dict of template vars to fill out the template
          - return something other than a dict and the view decorator will not
            process the template, but return the handler result as is.
            This includes returning a HTTPResponse(dict) to get,
            for instance, JSON with autojson or other castfilters.
    '''
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            result = func(*args, **kwargs)
            if isinstance(result, (dict, DictMixin)):
                tplvars = defaults.copy()
                tplvars.update(result)
                return template(tpl_name, **tplvars)
            return result
        return wrapper
    return decorator 
开发者ID:exiahuang,项目名称:SalesforceXyTools,代码行数:23,代码来源:bottle.py

示例2: view

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def view(tpl_name, **defaults):
    ''' Decorator: renders a template for a handler.
        The handler can control its behavior like that:

          - return a dict of template vars to fill out the template
          - return something other than a dict and the view decorator will not
            process the template, but return the handler result as is.
            This includes returning a HTTPResponse(dict) to get,
            for instance, JSON with autojson or other castfilters.
    '''
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            result = func(*args, **kwargs)
            if isinstance(result, (dict, DictMixin)):
                tplvars = defaults.copy()
                tplvars.update(result)
                return template(tpl_name, **tplvars)
            elif result is None:
                return template(tpl_name, defaults)
            return result
        return wrapper
    return decorator 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:25,代码来源:__init__.py

示例3: update

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def update(self, other=None, **kwargs):
        # copied from UserDict.DictMixin
        # Make progressively weaker assumptions about "other"
        if other is None:
            pass
        elif hasattr(other, 'iteritems'):
            for k, v in other.iteritems():
                self[k] = v
        elif hasattr(other, 'keys'):
            for k in other.keys():
                self[k] = other[k]
        else:
            for k, v in other:
                self[k] = v
        for k, v in kwargs.iteritems():
            self[k] = v 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-499373.py

示例4: view

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def view(tpl_name, **defaults):
    ''' Decorator: renders a template for a handler.
        The handler can control its behavior like that:
          - return a dict of template vars to fill out the template
          - return something other than a dict and the view decorator will not
            process the template, but return the handler result as is.
            This includes returning a HTTPResponse(dict) to get,
            for instance, JSON with autojson or other castfilters.
    '''
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            result = func(*args, **kwargs)
            if isinstance(result, (dict, DictMixin)):
                tplvars = defaults.copy()
                tplvars.update(result)
                return template(tpl_name, **tplvars)
            elif result is None:
                return template(tpl_name, defaults)
            return result
        return wrapper
    return decorator 
开发者ID:imiyoo2010,项目名称:teye_scanner_for_book,代码行数:24,代码来源:bottle.py

示例5: view

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def view(tpl_name, **defaults):
    """ Decorator: renders a template for a handler.
        The handler can control its behavior like that:

          - return a dict of template vars to fill out the template
          - return something other than a dict and the view decorator will not
            process the template, but return the handler result as is.
            This includes returning a HTTPResponse(dict) to get,
            for instance, JSON with autojson or other castfilters.
    """
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            result = func(*args, **kwargs)
            if isinstance(result, (dict, DictMixin)):
                tplvars = defaults.copy()
                tplvars.update(result)
                return template(tpl_name, **tplvars)
            elif result is None:
                return template(tpl_name, defaults)
            return result
        return wrapper
    return decorator 
开发者ID:warriorframework,项目名称:warriorframework,代码行数:25,代码来源:bottle.py

示例6: __setattr__

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def __setattr__(self, key, value):
            if key in ('_config', '_prefix'):
                self.__dict__[key] = value
                return
            depr('Attribute assignment is deprecated.') #0.12
            if hasattr(DictMixin, key):
                raise AttributeError('Read-only attribute.')
            if key in self and self[key] and isinstance(self[key], self.__class__):
                raise AttributeError('Non-empty namespace attribute.')
            self[key] = value 
开发者ID:Autodesk,项目名称:arnold-usd,代码行数:12,代码来源:__init__.py

示例7: __cmp__

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def __cmp__(self, other):
        # copied from UserDict.DictMixin
        if other is None:
            return 1
        if isinstance(other, UserDict.DictMixin):
            other = dict(other.iteritems())
        return cmp(dict(self.iteritems()), other) 
开发者ID:ActiveState,项目名称:code,代码行数:9,代码来源:recipe-499373.py

示例8: view

# 需要导入模块: import UserDict [as 别名]
# 或者: from UserDict import DictMixin [as 别名]
def view(tpl_name, **defaults):
    """ Decorator: renders a template for a handler.
        The handler can control its behavior like that:

          - return a dict of template vars to fill out the template
          - return something other than a dict and the view decorator will not
            process the template, but return the handler result as is.
            This includes returning a HTTPResponse(dict) to get,
            for instance, JSON with autojson or other castfilters.
    """

    def decorator(func):

        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            result = func(*args, **kwargs)
            if isinstance(result, (dict, DictMixin)):
                tplvars = defaults.copy()
                tplvars.update(result)
                return template(tpl_name, **tplvars)
            elif result is None:
                return template(tpl_name, defaults)
            return result

        return wrapper

    return decorator 
开发者ID:warriorframework,项目名称:warriorframework,代码行数:29,代码来源:bottle.py


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