[Zope-dev] zpatterns-0.4a4
mike
mike@if-site.com
Mon, 26 Jun 2000 19:13:05 +0800
Jephte CLAIN wrote:
>
> There is a bug (a feature?) in Specialist.getItem in zpatterns-0.4a4:
>
> def getItem(self, key):
> if hasattr(self.aq_base,'retrieveItem'):
> return self.retrieveItem(key=key) # XXX need DTML check?
>
> for rack in self.rackList:
> item = rack.__of__(self).getItem(key)
> return item
>
> This code should (IMHO) read:
>
> def getItem(self, key):
> if hasattr(self.aq_base,'retrieveItem'):
> 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
> return None
>
I also think so, Jephte. But I thought 'for rack ...' was just a shorter
form of
if len( rackList) > 0) :
return rackList[0].__of__( self).getItem( key)
else :
return None
Better you, Phillip, replace it with one of more clear forms - Jephte's
or mine.
By the way, I do not like this Rack list at all. Racks and Specialists
are both DataManagers with compatible interfaces (getItem, newItem).
IMHO, Specialists should have list of DataManagers. This make much sense
in context of combining Specialists - ZSession and ClientManager, for
example. It is not sufficient just to tune ZSession using
ClientManager's rack and ZClass, because in this case we are losing the
ClientManager's aspect in sessions. Of course, one always can create
delegating rack (and even rack-to-specialist bridge), but what do this
for if simple replacing rackList with dataManagerList will solve all
such problems?
(Oh Gott, help mine improvink mie English :-)
Mike