当前位置: 首页>>代码示例>>Python>>正文


Python IAnnotations.clear方法代码示例

本文整理汇总了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
开发者ID:plone,项目名称:plone.app.stagingbehavior,代码行数:43,代码来源:copier.py


注:本文中的zope.annotation.interfaces.IAnnotations.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。