放大镜形状注释
grokcore.annotation的Python项目详细描述
这个包提供了一个支持,以简化在 佐佩。
内容
Setting up ^{tt1}$
这个包的设置基本上类似于grokcore.component 包,请参阅其文档以了解详细信息。唯一的 您需要的额外ZCML线路是:
<include package="grokcore.annotation" />
把这个放在根zcml文件的顶部,但是在 包含grokcore.component配置的行。
Example
下面是一个使用注释的简单示例:
import grokcore.annotation from zope import interface # Create a model and an interface you want to adapt it to # and an annotation class to implement the persistent adapter. class Mammoth(grokcore.annotation.Model): pass class ISerialBrand(interface.Interface): unique = interface.Attribute("Brands") class Branding(grokcore.annotation.Annotation): grokcore.annotation.implements(ISerialBrand) unique = 0 # Grok the above code, then create some mammoths manfred = Mammoth() mumbles = Mammoth() # creating Annotations work just like Adapters livestock1 = ISerialBrand(manfred) livestock2 = ISerialBrand(mumbles) # except you can store data in them, this data will transparently persist # in the database for as long as the object exists livestock1.unique = 101 livestock2.unique = 102 # attributes not listed in the interface will also be persisted # on the annotation livestock2.foo = "something"
API Overview
基类
- Annotation
- 注释的基类。继承自 持久类。
- Model
- 要在其上使用批注的模型的基类。
- queryAnnotation(model, interface)
- 查询给定模型上的注释 接口。如果找到,则返回注释,否则不返回。这个 不会进行任何写操作。
- deleteAnnotation(model, interface)
- 查找给定注释并将其从模型中删除。
- LazyAnnotation
- 注释的基类。它只在 显式设置惰性属性的值。
- LazyAnnotationProperty
- 与LazyAnnotation一起工作的属性实现。
另外,grokcore.annotation包公开了 grokcore.component原料药。
Changes
3.0.1 (2018-01-17)
- 用@grok.implementer()替换grok.implements()的用法 全程指导。
3.0.0 (2018-01-12)
- 重新安排测试,以便travis ci也可以获取所有功能测试。
1.6 (2017-05-30)
- 添加LazyAnnotation和LazyAnnotationProperty。
- 放弃对Python2.6的支持,并声明支持Python3.4、3.5、3.6和Pypy。
1.5.1 (2016-01-29)
- 更新测试。
1.5 (2014-10-20)
-
修正一个棕色纸袋的释放。
1.4 (2014-10-17)
- 添加queryAnnotation()以返回注释。如果是,则不返回 不存在。此帮助程序永远不会在 数据库。
1.3 (2012-05-01)
- 使用grokcore.component.util中的provideAdapter()。
- 使包符合zope.org存储库策略。
1.2 (2009-12-13)
- 使用zope.container而不是zope.app.container。
1.1 (2009-09-18)
- 注释对象实际上变成了一个要注意的包含对象 它的上下文和名称。
- 在grok的发布信息中使用1.0b1 versions.cfg而不是本地 拷贝;所有grokcore包的本地拷贝太难了 保持。
1.0.1 (2009-06-30)
- 用正确的python版本重新加载到pypi 有个臭虫。
1.0 (2009-06-29)
- 通过分解注释组件创建了grokcore.Annotation, 格洛克和格洛克的指示。