[Zope-dev] Refresh and debugging product creation issues.....
Steve Spicklemire
steve@spvi.com
Sat, 7 Oct 2000 07:55:32 -0500 (EST)
Debugging products is a pain... restarting Zope all the time is a Pain....
THANK GOD for Shane Hathaway. ;-)
I am delighted to report general success with the Refresh product! My
only problem is while debugging the process of creating new EMarket
instances, I find that every time I run 'Refresh' I get a new
"EMarket" in the 'Available Objects' popup. A quick test of other
Products shows the same behavior.
Soo... I snooped through the product creation code and found
that Products.meta_types was being unconditionally appended to
every time context.registerClass was called.... so I changed
my initialize to this:
def initialize(context):
import Products
context.registerClass(
EMarket.EMarket,
permission='Add EMarkets',
constructors=(EMarket.addEMarketForm,
EMarket.addEMarket),
icon='emarket.gif',
)
found_count = 0
new_products_meta_types = []
for index in range(len(Products.meta_types)):
if Products.meta_types[index]['name'] == EMarket.EMarket.meta_type:
found_count = found_count + 1
if found_count == 1:
new_products_meta_types.append( Products.meta_types[index] )
else:
new_products_meta_types.append( Products.meta_types[index] )
Products.meta_types = tuple( new_products_meta_types)
In other words... only include the original version of EMarket.EMarket.meta_type
in the Product.meta_types tuple... if there are others... leave them out.
...and that seems to have solved the problem....
Does this seem like an OK idea?
thanks,
-steve