[Zope-dev] bug in zpatterns-0.4 ?

Jephte CLAIN Jephte.Clain@univ-reunion.fr
Tue, 27 Jun 2000 11:07:55 +0400


mike wrote:
> Jephte CLAIN wrote:
> > Rack.createItem (low level method) first calls Rack.getItem (higher
> > level method) to check the existence of the item.
> > This causes infinite loop in certain cases. It should (IMHO) call
> > Rack.retrieveItem instead
> Could you provide an example please?
My data is located in an SQL database. I want to have some associated
data in ZODB. ZPatterns is a perfect fit for this. When I first access a
SQL record, the corresponding data is created in ZODB:

def getItem(self, key):
  if self.sql_get(key=key):
    # ok it exists in the SQL database
    item = Rack.getItem(self, key)
    if item is None:
      # it does not exist in ZODB, create it
      item = Rack.newItem(self, key)
  else:
    item = None
  return item

This causes infinite loop because Rack.newItem calls Rack.createItem
which calls my (modified) getItem

regards,
jephte clain
jclain@univ-reunion.fr