本文整理汇总了Python中persistent.mapping.PersistentMapping.__setitem__方法的典型用法代码示例。如果您正苦于以下问题:Python PersistentMapping.__setitem__方法的具体用法?Python PersistentMapping.__setitem__怎么用?Python PersistentMapping.__setitem__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类persistent.mapping.PersistentMapping
的用法示例。
在下文中一共展示了PersistentMapping.__setitem__方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __setitem__
# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import __setitem__ [as 别名]
def __setitem__(self, key, value):
if key in self.data:
raise TypeError("Can't update key in AppendOnlyDict!")
if isinstance(value, (dict, list)):
raise TypeError("Can't add non-persistent mutable subobjects!")
if not PY3:
from types import InstanceType
if type(value) is InstanceType:
if not isinstance(value, Persistent):
raise TypeError(
"Can't add non-persistent mutable subobjects!")
PersistentMapping.__setitem__(self, key, value)
示例2: __setitem__
# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import __setitem__ [as 别名]
def __setitem__(self, name, index):
""" Add an object which implements
``repoze.catalog.interfaces.ICatalogIndex`` to the catalog.
No other type of object may be added to a catalog."""
if not ICatalogIndex.providedBy(index):
raise ValueError('%s does not provide ICatalogIndex')
return PersistentMapping.__setitem__(self, name, index)
示例3: __setitem__
# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import __setitem__ [as 别名]
def __setitem__(self, name, index):
index.__name__ = name
return PersistentMapping.__setitem__(self, name, index)
示例4: __setitem__
# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import __setitem__ [as 别名]
def __setitem__(self, key, item):
if not self.data.has_key(key):
self._keys.append(key)
return BaseDict.__setitem__(self, key, item)
示例5: __setitem__
# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import __setitem__ [as 别名]
def __setitem__(self, key, value):
PersistentMapping.__setitem__(self, key, value)
value.__parent__ = self
value.__name__ = key