[Checkins] SVN: lovely.tag/trunk/src/lovely/tag/ Added ssome simple
statistic functions for the tagging engine.
Jürgen Kartnaller
juergen at kartnaller.at
Mon Nov 20 03:21:20 EST 2006
Log message for revision 71188:
Added ssome simple statistic functions for the tagging engine.
Changed:
U lovely.tag/trunk/src/lovely/tag/README.txt
U lovely.tag/trunk/src/lovely/tag/engine.py
U lovely.tag/trunk/src/lovely/tag/interfaces.py
-=-
Modified: lovely.tag/trunk/src/lovely/tag/README.txt
===================================================================
--- lovely.tag/trunk/src/lovely/tag/README.txt 2006-11-19 22:22:45 UTC (rev 71187)
+++ lovely.tag/trunk/src/lovely/tag/README.txt 2006-11-20 08:21:18 UTC (rev 71188)
@@ -75,6 +75,8 @@
>>> sorted(engine.getTags(items=(1,), users=(u'srichter',)))
[u'USA', u'personal']
+ >>> sorted(engine.getTags(items=(1, 2), users=(u'srichter',)))
+ [u'USA', u'austria', u'lovely', u'personal']
>>> sorted(engine.getTags(items=(3,), users=(u'srichter',)))
[]
@@ -153,6 +155,20 @@
[u'jodok', u'srichter']
+Tagging Statistics
+------------------
+
+ >>> from lovely.tag.interfaces import ITaggingStatistics
+ >>> ITaggingStatistics.providedBy(engine)
+ True
+ >>> engine.tagCount()
+ 6
+ >>> engine.itemCount()
+ 3
+ >>> engine.userCount()
+ 2
+
+
Combining Queries
-----------------
Modified: lovely.tag/trunk/src/lovely/tag/engine.py
===================================================================
--- lovely.tag/trunk/src/lovely/tag/engine.py 2006-11-19 22:22:45 UTC (rev 71187)
+++ lovely.tag/trunk/src/lovely/tag/engine.py 2006-11-20 08:21:18 UTC (rev 71188)
@@ -27,7 +27,8 @@
from lovely.tag import interfaces, tag
class TaggingEngine(persistent.Persistent, contained.Contained):
- zope.interface.implements(interfaces.ITaggingEngine)
+ zope.interface.implements(interfaces.ITaggingEngine,
+ interfaces.ITaggingStatistics)
def __init__(self):
super(TaggingEngine, self).__init__()
@@ -39,11 +40,20 @@
# Used to generate ids for tag objects
self._tag_ids = intid.IntIds()
- # Our indeces for efficient querying
+ # Our indices for efficient querying
self._user_to_tagids = OOBTree.OOBTree()
self._item_to_tagids = IOBTree.IOBTree()
self._name_to_tagids = OOBTree.OOBTree()
+ def tagCount(self):
+ return len(self._name_to_tagids)
+
+ def itemCount(self):
+ return len(self._item_to_tagids)
+
+ def userCount(self):
+ return len(self._user_to_tagids)
+
def update(self, item, user, tags):
"""See interfaces.ITaggingEngine"""
tags_item = set(self._item_to_tagids.get(item, ()))
Modified: lovely.tag/trunk/src/lovely/tag/interfaces.py
===================================================================
--- lovely.tag/trunk/src/lovely/tag/interfaces.py 2006-11-19 22:22:45 UTC (rev 71187)
+++ lovely.tag/trunk/src/lovely/tag/interfaces.py 2006-11-20 08:21:18 UTC (rev 71188)
@@ -98,6 +98,19 @@
"""
+class ITaggingStatistics(zope.interface.Interface):
+ """A tagging engine that provides statistical information about itself"""
+
+ def tagCount():
+ """Return the number of tags in the tagging engine"""
+
+ def itemCount():
+ """Return the number of items in the tagging engine"""
+
+ def userCount():
+ """Return the number of users in the tagging engine"""
+
+
class ITaggable(zope.interface.Interface):
"""A marker interface to declare an object as being able to be tagged."""
More information about the Checkins
mailing list