diff --git a/organize/comment/README.txt b/organize/comment/README.txt
index f3a1df9..3fe1b52 100644
--- a/organize/comment/README.txt
+++ b/organize/comment/README.txt
@@ -45,6 +45,9 @@ to assign comments to this document.
>>> home = views['home']
>>> home.target = resources['d001.txt']
+ >>> from loops.organize.comment.base import commentStates
+ >>> component.provideUtility(commentStates(), name='organize.commentStates')
+
Creating comments
-----------------
diff --git a/organize/comment/base.py b/organize/comment/base.py
index 3ad956e..5b4ff95 100644
--- a/organize/comment/base.py
+++ b/organize/comment/base.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
+# Copyright (c) 2014 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,24 +18,46 @@
"""
Base classes for comments/discussions.
-
-$Id$
"""
from zope.component import adapts
-from zope.interface import implements
+from zope.interface import implementer, implements
+from cybertools.stateful.definition import StatesDefinition
+from cybertools.stateful.definition import State, Transition
+from cybertools.stateful.interfaces import IStatesDefinition
from cybertools.tracking.btree import Track
from cybertools.tracking.interfaces import ITrackingStorage
-from cybertools.tracking.comment.interfaces import IComment
+from loops.organize.comment.interfaces import IComment
+from loops.organize.stateful.base import Stateful
from loops import util
-class Comment(Track):
+@implementer(IStatesDefinition)
+def commentStates():
+ return StatesDefinition('commentStates',
+ State('new', 'new', ('accept', 'reject'), color='red'),
+ State('public', 'public', ('retract', 'reject'), color='green'),
+ State('rejected', 'rejected', ('accept'), color='grey'),
+ Transition('accept', 'accept', 'public'),
+ Transition('reject', 'reject', 'rejected'),
+ Transition('retract', 'retract', 'new'),
+ initialState='new')
+
+
+class Comment(Stateful, Track):
implements(IComment)
+ metadata_attributes = Track.metadata_attributes + ('state',)
+ index_attributes = metadata_attributes
typeName = 'Comment'
+ typeInterface = IComment
+ statesDefinition = 'organize.commentStates'
contentType = 'text/restructured'
+ def __init__(self, taskId, runId, userName, data):
+ super(Comment, self).__init__(taskId, runId, userName, data)
+ self.state = self.getState() # make initial state persistent
+
diff --git a/organize/comment/configure.zcml b/organize/comment/configure.zcml
index 74776fa..2b78430 100644
--- a/organize/comment/configure.zcml
+++ b/organize/comment/configure.zcml
@@ -12,6 +12,10 @@
set_schema="cybertools.tracking.comment.interfaces.IComment" />
+
+