add transition event
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2559 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
cd46c0a345
commit
7cd7a574c0
3 changed files with 31 additions and 1 deletions
|
@ -24,10 +24,11 @@ $Id$
|
|||
|
||||
from persistent.interfaces import IPersistent
|
||||
from persistent.mapping import PersistentMapping
|
||||
from zope import component
|
||||
from zope.component import adapts
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.stateful.interfaces import IStateful
|
||||
from cybertools.stateful.interfaces import IStateful, IStatefulIndexInfo
|
||||
from cybertools.stateful.definition import statesDefinitions
|
||||
|
||||
|
||||
|
@ -94,3 +95,19 @@ class StatefulAdapter(Stateful):
|
|||
statesAttr[self.statesDefinition] = value
|
||||
state = property(getState, setState)
|
||||
|
||||
|
||||
class IndexInfo(object):
|
||||
|
||||
implements(IStatefulIndexInfo)
|
||||
|
||||
availableStatesDefinitions = [] # to be overwritten by subclass!
|
||||
|
||||
def __init__(self, context):
|
||||
self.context = context
|
||||
|
||||
@property
|
||||
def tokens(self):
|
||||
for std in self.availableStatesDefinitions:
|
||||
stf = component.getAdapter(self.context, IStateful, name=std)
|
||||
yield ':'.join((std, stf.state))
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ class TransitionEvent(ObjectEvent):
|
|||
self.transition = transition
|
||||
self.previousState = previousState
|
||||
|
||||
|
||||
# dummy default states definition
|
||||
|
||||
defaultSD = StatesDefinition('default',
|
||||
|
|
|
@ -113,6 +113,18 @@ class IStatesDefinition(Interface):
|
|||
"""
|
||||
|
||||
|
||||
class IStatefulIndexInfo(Interface):
|
||||
""" Provide a list of tokens to be used for index the states
|
||||
of an object in the catalog.
|
||||
"""
|
||||
|
||||
tokens = Attribute('A sequence of strings to be used for indexing the '
|
||||
'states; format: [<statesdefinition name>:<state name>, ...].')
|
||||
|
||||
availableStatesDefinitions = Attribute('A sequence of strings with the '
|
||||
'names of all states definitions currently available.')
|
||||
|
||||
|
||||
class ITransitionEvent(IObjectEvent):
|
||||
""" Fires when the state of an object is changed.
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue