[Zope-PTK] content states
Steve Alexander
steve@cat-box.net
Mon, 17 Jul 2000 21:35:07 +0100
Steve Alexander wrote:
>
> * Does this multiple attribute thing really merit an interface of its
> own, rather than just an attributes and a method or two?
If we don't immediately go the ZPatterns way with this, here's a
straw-man interface. We should use an interface because it would make an
easy mix-in class, and Demeter's law suggests it's bad to just expose a
PersistentMapping, when we really want to say "this object has a
statespace".
def ContentState(self):
# For cataloguing as a KeywordIndex, sequence of strings
# Example: ['review:published', 'readbyadmin:no']
def ContentStateForMetaData(self):
# Map of name:state, suitable for use as catalog metadata.
# Example: {'review':'published', 'readbyadmin':'no'}
def getStateFor(self, name):
# Returns the state for a particular name
# Example: obj.getStateFor('review') returns 'published'
# Returns None if there is no state for that name.
def changeState(self, name, newstate, reason=''):
# Changes the state associated with name to newstate.
# A reason may be recorded or auditing purposes.
# sometimes the auditing subsystems will insist on
# having a reason.
# A new name:state gets created if none existed before.
def delState(self, name, reason=''):
# Like changeState, but removes the name
# from the mapping.
Would namespaces be useful? I think so, if other subsystems get to
contribute to an object's state. Therefore, instead of the two-part
name:state as suggested above, we could have a three-part
namespace:name-state. For example, "reviewing:review-published".
--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net