[Twisted-Python] Woven: can't get view notification to work

Gavrie Philipson gavrie at disksites.com
Wed Dec 10 05:20:02 EST 2003


I'm trying to use the notify method of a model to update its views while a page is being rendered. For sake of simplicity, let's assume there's a global data structure which is updated while the page is rendered. A view which renders this data structure should then be called again so that it'll render the updated version.

Unfortunately, I can't get it to work: even though the view is being called again by the notify method, the new view doesn't show up on the final page -- as if it ran only once.

I have attached a small test program (test_notify.py).
Here's a log of what happens when running it, and connecting from a Web browser:

> twistd -ny test_notify.py
2003/12/10 12:08 IST [-] Log opened.
2003/12/10 12:08 IST [-] twistd 1.1.0 (/usr/bin/python 2.3.2) starting up
2003/12/10 12:08 IST [-] reactor class: twisted.internet.default.SelectReactor
2003/12/10 12:08 IST [-] Loading test_notify.py...
2003/12/10 12:08 IST [-] Loaded.
2003/12/10 12:08 IST [-] twisted.web.server.Site starting on 8000
2003/12/10 12:08 IST [-] Starting factory <twisted.web.server.Site instance at 0xbf04f02c>
2003/12/10 12:08 IST [HTTPChannel,0,] ### mydict: {'hello': 'world'}
2003/12/10 12:08 IST [HTTPChannel,0,] ### mydict: {'foo': 'bar', 'hello': 'world'}
2003/12/10 12:08 IST [HTTPChannel,0,] - - [10/Dec/2003:10:08:47 +0000] "GET / HTTP/1.1" 200 88 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 Firebird/0.7"

The 'mydict' data structure is being updated by one of the models on the page, and it is rendered by one of the views. The model notifies the view, and the view is run on the updated data -- as is evident from the second "## mydict:" line. 

However, the final page just shows {'hello': 'world'} instead of the expected {'foo': 'bar', 'hello': 'world'}.

Any ideas as to why this happens?

My platform: Twisted 1.1.0 with Python 2.3.2 on a Linux machine.


-- Gavrie Philipson.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_notify.py
Type: application/octet-stream
Size: 1000 bytes
Desc: test_notify.py
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20031210/30353ed2/attachment.obj 

More information about the Twisted-Python mailing list