[Zope] Refresh ZEO interactive python when changing product's code? Was: Adding __setitem__

Jeff Kowalczyk jtk@yahoo.com
Wed, 9 Oct 2002 14:33:29 -0400


FWIW, that problem with "AttributeError: __setitem__" was that my console (PythonWin
connected via ZEO) isn't aware of product refreshes. I'm kind of in uncharted territory
here (for me), but what should I be doing to get the python console to recognize the
updated python product code when I run a refresh from the ZEO-connected Zope ZMI? Here's a
sample console problem demonstrating the symptoms, and some of the things I've tried to
avoid closing out the python console each time I change python code in a product. Thanks
for any help anyone can offer.

This is probing how to get the console to recognize that __setitem__'s implementation has
changed from 'print test1' to 'print test2' after the first call.

PythonWin 2.1.3 (#35, Apr  8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au)
>>> import Zope, Products, ZEO, ZODB
>>> storage = ZEO.ClientStorage.ClientStorage(('localhost', 8800))
>>> db = ZODB.DB(storage)
>>> conn = db.open()
>>> dbroot = conn.root()
>>> app = dbroot.get('Application')
>>> app.Formulator.form3.str1['required'] = 0
test1
>>> app.Formulator.form3.str1['required'] = 0  # Prod refresh in ZMI, expecting 'test2'
test1
>>> storage.close()
>>> storage = ZEO.ClientStorage.ClientStorage(('localhost', 8800))
>>> db = ZODB.DB(storage)
>>> conn = db.open()
>>> dbroot = conn.root()
>>> app = dbroot.get('Application')
>>> app.Formulator.form3.str1['required'] = 0 # looking for 'test2'
test1
>>> reimport Products.Formulator.Form
>>> app.Formulator.form3.str1['required'] = 0 # looking for 'test2'
test1
>>> reload(Products.Formulator)
<module 'Products.Formulator' from
'C:\PROGRA~1\Zope\lib\python\Products\Formulator\__init__.pyc'>
>>> app.Formulator.form3.str1['required'] = 0 # expecting 'test2'
test1
>>> Zope.ZPublisher.Zope('/Control_Panel/Products/Formulator/manage_performRefresh',
u='Username:password')
Status: 200 OK (snip)
>>> app.Formulator.form3.str1['required'] = 0 # looking for 'test2'
test1
>>>