本文整理汇总了Python中BTrees.OIBTree.OIBTree.values方法的典型用法代码示例。如果您正苦于以下问题:Python OIBTree.values方法的具体用法?Python OIBTree.values怎么用?Python OIBTree.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTrees.OIBTree.OIBTree
的用法示例。
在下文中一共展示了OIBTree.values方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MessageService
# 需要导入模块: from BTrees.OIBTree import OIBTree [as 别名]
# 或者: from BTrees.OIBTree.OIBTree import values [as 别名]
class MessageService(Persistent, Location):
interface.implements(IMessageService)
def __init__(self, storage):
self.__parent__ = storage
self.index = OIBTree()
self.unread = Length(0)
def __len__(self):
return len(self.index)
def __iter__(self):
return iter(self.index.values())
def __contains__(self, key):
msg = self.__parent__.getMessage(key)
if msg is not None:
return True
else:
return False
def get(self, msgId, default=None):
msg = self.__parent__.getMessage(msgId)
if msg is not None:
if msg.__date__ in self.index:
return msg
return default
def append(self, message):
message.__parent__ = self
if self.__parent__.readStatus(message):
self.unread.change(1)
self.index[message.__date__] = message.__id__
def remove(self, message):
id = message.__date__
if id in self.index:
del self.index[id]
if self.__parent__.readStatus(message) and self.unread() > 0:
self.unread.change(-1)
def create(self, **data):
raise NotImplemented('create')