本文整理汇总了Python中zope.annotation.interfaces.IAnnotations.clear方法的典型用法代码示例。如果您正苦于以下问题:Python IAnnotations.clear方法的具体用法?Python IAnnotations.clear怎么用?Python IAnnotations.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zope.annotation.interfaces.IAnnotations
的用法示例。
在下文中一共展示了IAnnotations.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _replaceBaseline
# 需要导入模块: from zope.annotation.interfaces import IAnnotations [as 别名]
# 或者: from zope.annotation.interfaces.IAnnotations import clear [as 别名]
def _replaceBaseline( self, baseline ):
wc_id = self.context.getId()
wc_container = aq_parent( self.context )
# copy all field values from the working copy to the baseline
for schema in iterSchemata( baseline ):
for name, field in getFieldsInOrder( schema ):
# Skip read-only fields
if field.readonly:
continue
if field.__name__ == 'id':
continue
try:
value = field.get( schema( self.context ) )
except:
value = None
# TODO: We need a way to identify the DCFieldProperty
# fields and use the appropriate set_name/get_name
if name == 'effective':
baseline.effective_date = self.context.effective()
elif name == 'expires':
baseline.expiration_date = self.context.expires()
elif name == 'subjects':
baseline.setSubject(self.context.Subject())
else:
field.set( baseline, value )
baseline.reindexObject()
# copy annotations
wc_annotations = IAnnotations(self.context)
baseline_annotations = IAnnotations(baseline)
baseline_annotations.clear()
baseline_annotations.update(wc_annotations)
# delete the working copy
wc_container._delObject( wc_id )
return baseline