[Zope-dev] Tip: Skinscript Debugging

Steve Alexander steve@cat-box.net
Sun, 14 Jan 2001 13:14:12 +0000


When debugging skinscript, especially tricky dependencies between what 
gets computed when during state changes, do the following:

1: Run zope in debug mode (-D)

2: Put an external method called print_ in the root of your ZODB, with 
the code:

   def print_(s):
     print s

3: In your SkinScript, if you want to know when a trigger is called, or 
when a set of attributes get computed, use this kind of thing:

WITH QUERY foo(id=some_id) COMPUTE
   thing=RESULT,
   bar=baz,
   _printout_foo=self.print_('query foo called, id=%s' % some_id)
OTHERWISE LET
   thing=_.None,
   bar='no bar',
   _printout_foo=self.print_('query foo called, otherwise clause')


WHEN OBJECT CHANGED CALL
print_('CHANGED start'),
Catalog
.uncatalog_object(_.string.join(self.getPhysicalPath(),'/')),
print_('CHANGED middle'),
Catalog
.catalog_object(self, _.string.join(self.getPhysicalPath(),'/')),
print_('CHANGED end')


4: Read the debug printout, and work out that you're computing 
attributes for cataloging before changing the attributes they depend on.

5: Amend code and skinscript, test, document code, sleep.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net