[Zope-PTK] content states

Steve Alexander steve@cat-box.net
Tue, 18 Jul 2000 23:40:44 +0100


"Dan L. Pierson" wrote:
> 
> Steve Alexander writes:
>  >   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.
> 
> IMHO, there's an unnecessary inconsistency between the first name and
> the later two.  I'd make all of them end in your choice of 'State' or
> 'StateFor' because they all require a state name argument.

I agree. Thanks for noting that.

Which is better; getState or getStateFor ?

The term getState is shorter, but getStateFor makes it clearer that the
meaning of the method-call is dependent on the name of state that's been
given.

>  > 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".
> 
> Hmmm, I don't know.  It's superficially attractive, but it may well be
> unnecessary complexity...

Perhaps the namespaces bit can be optional? We can use a default
namespace of some sort, and default values for method arguments.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net