context.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:charm-helpers 作者: juju 项目源码 文件源码
def __setitem__(self, key, value):
        if self.unit != hookenv.local_unit():
            raise TypeError('Attempting to set {} on remote unit {}'
                            ''.format(key, self.unit))
        if value is not None and not isinstance(value, six.string_types):
            # We don't do implicit casting. This would cause simple
            # types like integers to be read back as strings in subsequent
            # hooks, and mutable types would require a lot of wrapping
            # to ensure relation-set gets called when they are mutated.
            raise ValueError('Only string values allowed')
        hookenv.relation_set(self.relid, {key: value})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号