[Zope-dev] Refresh ZEO interactive python when changing product's code?

Jeff Kowalczyk jtk@yahoo.com
Thu, 10 Oct 2002 12:35:41 -0400


This is OT, but I have a deadline approaching and needed to go where the ZEO users are so
I can get this figured out as soon as possible, in case zope-general doesn't yield a
suggestion. Thanks in advance for any help anyone can offer, hopefully this is old-hat to
some of the people on this list.

I'm using CVS ZEO2 with Zope 2.5.1 connected via ClientStorage on the same machine. My
python console is PythonWin installed under Zope's python. Long story short, I'm adding a
few methods to Formulator, but the question here is about python product development in
general.

My console isn't aware of product refreshes. 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.
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
>>>