Grok-like configuration for Zope annotations
This package provides a support to simplify the use of annotations in Zope.
This package is essentially set up like the grokcore.component package, please refer to its documentation for details. The only additional ZCML line you will need is:
<include package="grokcore.annotation" />
Put this somewhere near the top of your root ZCML file but below the line where you include grokcore.component’s configuration.
Here a simple example of use of an annotation:
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"
- Base class for an Annotation. Inherits from the persistent.Persistent class.
- Base class for a Model on which you want to use an annotation.
- queryAnnotation(model, interface)
- Query the annotation on the given model for the given interface. Return the annotation if found, None otherwise. This will not make any write operation.
- deleteAnnotation(model, interface)
- Look for the given annotation and delete it from the model.
- Base class for an annotation. It only writes a database object when explicitly setting values on the lazy properties.
- Property implementation that works with LazyAnnotation.
In addition, the grokcore.annotation package exposes the grokcore.component API.
- grokcore.annotation.testing.warn was removed as it was not used internally. If you still need it, a copy is in grokcore.view.testing.
- Add _p_changed property to the LazyAnnotation object, proxying it to the actual Storage object. That way the “API” for explicitely marking objects as changed is the same regaredless of a “normal” annotation object or an lazy annotation object.
- Add support for Python 3.7, 3.8 and 3.9.
- Drop support for Python 3.4.
- Add support for FieldUpdatedEvent in LazyPropertyAnnotation to mirror the behavior of zope.schema.
- Replace the use of grok.implements() with the @grok.implementer() directive throughout.
- Rearrange tests such that Travis CI can pick up all functional tests too.
- Add LazyAnnotation and LazyAnnotationProperty.
- Drop support of Python 2.6 and claim support for Python 3.4, 3.5, 3.6 and PyPy.
- Update tests.
- Updating MANIFEST.in, fixing a brown paper bag release.
- Add queryAnnotation() to return an annotation. Return None if it doesn’t exists. This helper will never do any write operation in the database.
- Add deleteAnnotation() to delete an annotation (if it exists).
- Use provideAdapter() from grokcore.component.util.
- Made package comply to zope.org repository policy.
- Use zope.container instead of zope.app.container.
- The annotation object become really a contained object to be aware of its context, and name.
- Use 1.0b1 versions.cfg in Grok’s release info instead of a local copy; a local copy for all grokcore packages is just too hard to maintain.
- Reupload to pypi with a correct version of Python which doesn’t have a distutils bug.
- Created grokcore.Annotation by factoring annotation components, grokkers and directives out of Grok.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for grokcore.annotation-3.2-py2.py3-none-any.whl