[Zope-dev] bug in zpatterns-0.4 ?

mike mike@if-site.com
Tue, 27 Jun 2000 15:34:00 +0800


Jephte CLAIN wrote:
> 
> mike wrote:
> > > This causes infinite loop because Rack.newItem calls Rack.createItem
> > > which calls my (modified) getItem
> >
> > 1. Leave getItem untouched. Move all that SQL-related stuff into the
> > retrieveItem method which *is intended* to be overriden.
> >
> > 2. Move newItem stuff into Specialist. You have mixed 'Restaurant' and
> > the 'FoodStore' in this snippet :-) Do this instead:
> Good point. I have to remember that getItem/newItem are not for
> overriding.
> But the problem remains the same. a low level method (createItem) should
> not call a high level method (getItem)

There is no problem. Look at protocol:

Specialist.getItem -> 
  Rack.getItem ->
    Rack.retrieveItem <- None
  Rack.getItem <- None
Specialist.getItem ->
  Rack.newItem ->
    Rack.createItem ->
      Rack.getItem ->
        Rack.retrieveItem <- None
      Rack.getItem <- None
    Rack.createItem <- item
  Rack.newItem <- item
Specialist.getItem <- item

There is no way to infinite recursion if Rack.getItem is leaved
untouched. getItem/newItem are not a high level methods, they are *part
of DataSource's protocol* which *implemented* in Rack with retrieveItem
and buddies.

Mike