Just for the sake of helping out the next poor sod who has this problem:
I have the following model class:
class Category(SQLObject):
slug= UnicodeCol( length=40 )
name= UnicodeCol( length=40 )
description= UnicodeCol()
parent= ForeignKey( "Category", dbName="parent_id", default=None )
children= MultipleJoin( "Category", joinColumn="parent_id" )
items= RelatedJoin( "Product",
intermediateTable="category_product" )
def deep_items( self, items=[] ):
'''
Retrieve ALL items in this category regardless of whether
they appear
in a subcategory.
'''
items.extend( self.items )
for cat in self.children:
cat.deep_items( items )
return items
The problem stemmed from the default value for items. The next time
deep_items was run, the items list contained the entries from the
previous invocation. And of course, their transactions had already
expired.
I now have the method defined as:
def deep_items( self, items=None ):
'''
Retrieve ALL items in this category regardless of whether
they appear
in a subcategory.
'''
if not items:
items=[]
items.extend( self.items )
for cat in self.children:
cat.deep_items( items )
return items
And it seems to work.
I definitely echo Jeremy's sentiment: Kid templates are a pain to
debug. It was only on my wife's suggestion that I strip out all the
computed values with dummy data and slowly add stuff back that I
found the problem.
--
Jeff Watkins
http://newburyportion.com/
“In science it often happens that scientists say, ‘You know that’s a
really good argument; my position is mistaken,’ and then they
actually change their minds and you never hear that old view from
them again. They really do it. It doesn’t happen as often as it
should, because scientists are human and change is sometimes painful.
But it happens every day. I cannot recall the last time something
like that happened in politics or religion.” Carl Sagan, 1987