Hello ZPatterns Folk.....
I'm trying to implement 'delagation' with a custom Specialist. The idea,
(I think this is one of the goals of ZPatterns... to allow delegation
of responsibility after the Framework is built...)
a) MarketItemManager (Python subclass of Specialist) Some of methods, both DTML
and plain old Python Methods, are *meant* to be acquire by the objects (DataSkins)
b) ThingManager (ZClass subclass of Specialist). This is really just a test
class that is supposed to represent some later developer integrating
my ZPattern based EMarket into their application, (e.g., inventory or
in MarketItemManager I've defined a 'retrieveItem' (this would really be
done by the integrator...) that does something like this:
with the hope that when the Specialist class gets traversed
it will execute:
def __bobo_traverse__(self, REQUEST, name):
ob = getattr(self, name, _marker)
if ob is _marker:
ob = self.getItem(name) <--- traversal invokes getItem....
if ob is not None:
def getItem(self, key):
"""Get an item"""
if hasattr(self.aq_base,'retrieveItem'): <--- getItem invokes
return self.retrieveItem(key=key) # XXX need DTML check?
for rack in self.rackList:
item = rack.__of__(self).getItem(key)
if item is not None: return item
So my retrieve item gets called..... *unfortunately* it gets
called without any namespace parameter... so my retrieveItem
DTML method has no way to acquire a namespace so that it can
delagate to something else!
So... here is what I did... I defined a method in my Python
subclass of Specialist..
"""A Market Item Manager"""
# Specify a name for the item type:
def retrieveItem(self, key):
""" get an item...."""
return self.__of__(self).delegateRetrieve(self, None, key=key)
Then I made a DTML method called 'delegateRetrieve' like so:
this way, my integrator can edit 'delegateRetrieve' to point
to whatever Specialist he wants to... and I have a Python
implementation of retrieveItem.
Does this sound OK? Am I working way too hard here?
(I feel like I am! ;-> )
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -