+ def zapTo(self, reftozap):
+ self.session.nav.playService(reftozap)
+
+# implements the 'render'-call.
+# this will act as a downstream_element, like a renderer.
+class OneTimeElement(Element):
+ def __init__(self, id):
+ Element.__init__(self)
+ self.source_id = id
+
+ # CHECKME: is this ok performance-wise?
+ def handleCommand(self, args):
+ for c in args.get(self.source_id, []):
+ self.source.handleCommand(c)
+
+ def render(self, stream):
+ t = self.source.getHTML(self.source_id)
+ if isinstance(t, unicode):
+ t = t.encode("utf-8")
+ stream.write(t)
+
+ def destroy(self):
+ pass
+
+class StreamingElement(OneTimeElement):
+ def __init__(self, id):
+ OneTimeElement.__init__(self, id)
+ self.stream = None
+
+ def changed(self, what):
+ if self.stream:
+ self.render(self.stream)
+
+ def setStream(self, stream):
+ self.stream = stream