lovely.tag (1.1.1)
- Homepage of lovely.tag: http://pypi.python.org/pypi/lovely.tag
- lovely.tag repository: http://svn.zope.org/lovely.tag
- Description source: http://svn.zope.org/lovely.tag/trunk/src/lovely/tag/README.txt
Tagging
A tagging engine allows you to assign tags to any type of object by an user. A tag is a simple string.
>>> from lovely import tag
Tagging Engine
The tagging engine provides the capabilities to manipulate and and query tagged items.
>>> engine = tag.TaggingEngine()
>>> engine
<TaggingEngine entries=0>
The first step is to associate tags with an item for a user. Items are referenced by their intId, the user is a system-wide unique string and the tags is a simple list of strings.
Before updating the engine we need to ensure that persistent objects can be adapted to key references:
>>> import zope.component
>>> from zope.app.keyreference import testing
>>> zope.component.provideAdapter(testing.SimpleKeyReference)
Instead providing a separate API for adding and updating tags, both actions are done via the update() method. Think of it as updating the tagging engine.
>>> engine.update(1, u'srichter', [u'USA', u'personal'])
>>> engine.update(2, u'srichter', [u'austria', u'lovely'])
>>> engine.update(3, u'jodok', [u'Austria', u'personal'])
>>> engine.update(2, u'jodok', [u'austria', u'lovely', u'work'])
Next you can ask the engine several questions.