Re: athena duplicate messages issue
"Michael Graz" <[email protected]> Sun, 14 Jan 2007 16:34:48 +0000
| Newsgroups | gmane.comp.python.quotient.dev |
|---|---|
| Message-ID | <[email protected]> |
ok here is an example that shows the lockup. Click
http://localhost:8080/page1 to load Page(1) - this works. But then in page1
click on page2 link - this locks. It appears there are some response
messages left over from page1 that get sent to page2. Thanks again
#----test_rmd.py-------------------------------------------------------
from twisted.application import service, strports
from twisted.python import util
from nevow import appserver, rend, athena, loaders, tags as T
xmlns_nevow = 'xmlns:nevow="http://nevow.com/ns/nevow/0.1"'
xmlns_athena = 'xmlns:athena="http://divmod.org/ns/athena/0.7"'
class Fragment(athena.LiveFragment):
jsClass = u'Fragment.Nevow'
docFactory = loaders.xmlstr ('''<div %s %s nevow:render="liveFragment">
<div id="fragment"/>
</div>''' % (xmlns_nevow, xmlns_athena, ))
def add_paragraph (self, text):
self.callRemote ('add_paragraph', unicode(text))
class Page(athena.LivePage):
addSlash = True
docFactory = loaders.xmlstr ('''<html %s><head><nevow:invisible
nevow:render="liveglue"/></head>
<body>
<div nevow:render="page_num"/>
<div nevow:render="fragment"/>
<div nevow:render="run_test"/>
<div nevow:render="next"/>
</body></html>''' % xmlns_nevow)
def __init__(self, page_num, *a, **kw):
self.page_num = page_num
super(Page, self).__init__(*a, **kw)
self.jsModules.mapping[u'Fragment'] = util.sibpath(__file__,
'test_rmd.js')
def render_page_num (self, ctx, data):
return ctx.tag ['page: %s, clientID: %s' % (self.page_num,
self.clientID, )]
def render_fragment (self, ctx, data):
self.fragment = Fragment ()
self.fragment.page = self
return ctx.tag [self.fragment]
def render_run_test (self, ctx, data):
self.fragment.add_paragraph ('p1')
self.fragment.add_paragraph ('p2')
return ''
def render_next (self, ctx, data):
next_page = '/page%s' % (self.page_num + 1)
return ctx.tag [T.a(href=next_page)[next_page]]
class Index (rend.Page):
addSlash = True
docFactory = loaders.xmlstr('<html><body><a
href="page1">page1</a></body></html>')
def child_page1 (self, ctx): return Page(1)
def child_page2 (self, ctx): return Page(2)
def child_page3 (self, ctx): return Page(3)
application = service.Application ('tester')
twisted_service = strports.service ('8080', appserver.NevowSite (Index()))
twisted_service.setServiceParent (application)
#----------------------------------------------------------------------
//----test_rmd.js------------------------------------------------------
// import Nevow.Athena
var Fragment = {};
Fragment.Nevow = Nevow.Athena.Widget.subclass('Fragment.Nevow');
Fragment.Nevow.methods(
function add_paragraph(self, text) {
var elem = document.getElementById('fragment');
var p = document.createElement('p');
elem.appendChild(p);
p.appendChild(document.createTextNode(text));
}
);
//---------------------------------------------------------------------