[Zope3-Users] Changing object type in Object field.
thealx at poczta.onet.pl
thealx at poczta.onet.pl
Tue Jul 4 05:58:03 EDT 2006
Hi,
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 view?
Best Regards!
Alek.
More information about the Zope3-users
mailing list