Hi,
Athena seems like the coolest since the Russians invented the wheel :)
With the Athena tutorial at divmod.org as a starting point, I'm trying to
make a page with 2 frames. Both need to send/receive events to the server,
plus they need to communicate with each other.
Left frame will show a table of tablenames in a database. Clicking a
tablename will cause data from this DB table to show up in the right frame.
Clicking an item in the right frame will call a server method for further
processing.
As I understand it, both frames need to be fully-fledged LivePages, right?
They can use the same JS file, only they must have different JS classes(?)
Things work fine as long as only Left Frame is live, just causing data to
show in Right Frame.
When Right Frame also becomes a LivePage, it starts to behave funny:
- Clicking an item in Left Frame - nothing happens.
- Clicking same item again (not dblclick) - both events are seen by the
server.
So, something seems to be "sitting on" the first click, and when the 2nd one
comes, both are sent. I must have made some redundant stuff here, but can't
figure out what.
Below are some code fragments. Grateful for any hints, and thanks for a
great toolkit!
-------------------------- Server: -------------------------------
class FrameSet(rend.Page):
docFactory = loaders.stan(
T.frameset(cols="50%, *")[
T.frame(name="left_pane", src="leftPane"),
T.frame(name="right_pane", src="rightPane"),
]
)
....
class LeftPane(athena.LivePage):
addSlash = True
docFactory = loaders.xmlfile('visPlan.html')
def render_commElement(self, ctx, data):
print '***LEFT COMM ELEMENT***'
f = LeftCommElement()
f.setFragmentParent(self)
return ctx.tag[f]
...
class RightPane(athena.LivePage):
docFactory = loaders.stan(
T.html[
T.head(render=T.directive('liveglue')),
T.body[
T.div(id='firstDiv', render= T.directive('commElement'))
]
]
)
def render_commElement(self, ctx, data):
print '***RIGHT COMM ELEMENT***'
f = RightCommElement()
f.setFragmentParent(self)
return ctx.tag[f]
...
class LeftCommElement(athena.LiveElement):
jsClass = u'VisPlan.LeftComm'
docFactory = loaders.stan(T.div(render=T.directive('liveElement'))[
T.input(type="button", value="Show Clients", onclick='
Nevow.Athena.Widget.get(this).show_clients()'),
...
class RightCommElement(athena.LiveElement):
jsClass = u'VisPlan.RightComm'
docFactory = loaders.stan(T.div(render=T.directive('liveElement')))
...
-------------------------- JS file: -------------------------------
// import Nevow.Athena
VisPlan = {};
VisPlan.LeftComm = Nevow.Athena.Widget.subclass('VisPlan.LeftComm');
VisPlan.RightComm = Nevow.Athena.Widget.subclass('VisPlan.RightComm');
VisPlan.LeftComm.method(
'table_cell_clicked',
function(self, arg) {
self.callRemote('tableCellClicked', arg);
});
VisPlan.RightComm.method(
'gif_clicked',
function(self, arg) {
self.callRemote('gifClicked', arg);
});
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web