本文整理匯總了Python中BTrees.IIBTree.IISet.remove方法的典型用法代碼示例。如果您正苦於以下問題:Python IISet.remove方法的具體用法?Python IISet.remove怎麽用?Python IISet.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BTrees.IIBTree.IISet
的用法示例。
在下文中一共展示了IISet.remove方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FilteredSetBase
# 需要導入模塊: from BTrees.IIBTree import IISet [as 別名]
# 或者: from BTrees.IIBTree.IISet import remove [as 別名]
class FilteredSetBase(Persistent):
def __init__(self, id, expr):
self.id = id
self.expr = expr
self.clear()
def clear(self):
self.ids = IISet()
def index_object(self, documentId, obj):
raise RuntimeError,'index_object not defined'
def unindex_object(self,documentId):
try: self.ids.remove(Id)
except: pass
def getId(self): return self.id
def getExpression(self): return self.expr
def getIds(self): return self.ids
def getType(self): return self.meta_type
def setExpression(self, expr): self.expr = expr
def __repr__(self):
return '%s: (%s) %s' % (self.id,self.expr,map(None,self.ids))
__str__ = __repr__
示例2: ZchSite
# 需要導入模塊: from BTrees.IIBTree import IISet [as 別名]
# 或者: from BTrees.IIBTree.IISet import remove [as 別名]
#.........這裏部分代碼省略.........
raise KeyError, id
# make sure it's in our list of children
if not self.ids.has_key(id):
raise KeyError, id
# return the posting
return self.data[id].__of__(self)
security.declareProtected(View, 'zchcrypt')
def zchcrypt(self,word,key):
import hmac, base64
h = hmac.new(key)
h.update(word)
return base64.encodestring(h.digest())[:-3]
security.declareProtected(View, 'zchfqdn')
def zchfqdn(self,n):
return getfqdn(n)
security.declarePrivate('delItem')
def delItem(self,id):
if not self.data.has_key(id):
return
if self.ids.has_key(id): # article
article = self.data[id].__of__(self)
for comment_id in article.ids:
obj = self.data[comment_id].__of__(article)
self.uncatalog_object(obj.getPhysicalPath())
del self.data[comment_id]
self.uncatalog_object(article.getPhysicalPath())
del self.data[id]
self.ids.remove(id)
else: # comment
parent = self.data[self.data[id].parent_id].__of__(self)
# remove it from it's parents list of ids
obj = self.data[id].__of__(parent)
self.uncatalog_object(obj.getPhysicalPath())
del self.data[id]
parent.ids.remove(id)
security.declarePrivate('createId')
def createId(self):
id=int(time())
while self.data.has_key(id):
id=id+1
return id
security.declarePrivate('data_map')
def data_map(self,ids):
result=[]
for id in ids:
result.append(self.data[id].__of__(self))
return result
security.declareProtected(View, 'article_list')
def article_list(self, size=None):
""" returns article items """
def cmp_by_modified(x, y):
return cmp(y.modified, x.modified)
items = self.data_map(self.ids)
items.sort(cmp_by_modified)
if size:
items = items[:size]
for i in range(len(items)):