放大镜形状注释

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()以返回注释。如果是,则不返回 不存在。此帮助程序永远不会在 数据库。
  • 添加删除{ TT13}$以删除注释(如果存在)。

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, 格洛克和格洛克的指示。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何忽略缓冲读取器中在“”之后的行的其余部分,或行上的特定字符?   java在db中创建空对象或稍后保存   java如何实现UI无关的后台工作任务   java未能在Android中从BaseAdapter扩展的类中启动Tactivity?   java斐波那契迭代移动数组[]   安卓从文件读取提供了java。木卫一。StreamCorruptedException:无效的流标头:73720027   java计算矩形中的六边形数?   仅使用Java 1.5(或更早版本)读写XML   java如果所有元素都以相同的bucked结尾,为什么要进行大小调整?   java Apache POI Excel在xx中发现无法读取的内容。xlsx   swing我可以在普通java应用程序中使用GWTGUI吗?   来自自定义Java客户端的http删除请求的行为与邮递员不同   运行批处理文件时,java当前目录无效   使用TypeReference将java字符串转换为ArrayList<STRING>   documentlistener突出显示所有匹配词Java