I have some object, let's say MyObject. The object should trigger some action, 
based on some decision based on some conditions.

There are possible a few different kinds of decisions, so I have done Decider 
helper object, and a few subclasses - because each kind of decision requires 
different params. Accompanying interfaces are below:

class IDecider(Interface):
    def needTriggerAction():
        "Returns True if need to trigger action".

class IInactivityDecider(IDecider):
    inactivity_period = Int(title=u"Inactivity Period", default=3)

class IDueDateDecider(IDecider):
    due_date = DateTime(title=u"Due Date")

I have decider Object field in IMyObject schema (MyObject delegates the 
decision to self.decider.needTriggerAction method)

class IMyObject(Interface):
    decider = Object(schema=IDecider, title=u"Condition")

*First question*: is this design (delegation to subobject implementing specific 
interface) reasonable, or in Zope I should do that other way?

*Second question*: Can object implementing IDueDateDecider (inherited from 
IDecider) be used in decider field (which has specified schema=IDecider)? How 
to ensure that proper schema (i.e IDueDateDecider instead of IDecider) will be 
displayed in ObjectWidget?

*Third question*: What way would you suggest to allow web user dynamically 
'switch' decider object in MyObject (i.e change a kind of decision, for example 
from IInactivityDecider to IDueDateDecider) - preferably using formlib-based 

Best Regards!
Zope3-users mailing list

Reply via email to