[Twisted-web] livepage and IClientHandle().transient
Alessandro
aleuser at inwind.it
Sat Jun 24 07:23:43 CDT 2006
Valentino Volonghi aka Dialtone wrote:
> Check that you are using livepage.LivePage as a base class and report
> here the code you are using _completely_.
At the bottom of this email.
I'm using nevow from svn, last revision.
Python 2.4.1
>> I'm going to use the server side sessions and something similar
>> "return client.get(btn_idname).disable=true"... but I don't like it.
>
> Sessions should not be used at all because you must always be able to
> serialize them and their fields should remain somewhat fixed.
I can't understand: why sessions should be "serializzable"? Do you mean
that I should be able to write them to a file whenever I want?
> I suggest moving to Athena which is newer and more actively maintained
> and better overall, moving from one to the other is not very complex
> or hard if your app is not medium-big and there is a considerable gain
> in code complexity using Athena (less closures and such).
Probably you are right; my app is only made by few test modules. I have
choosed livepage because It is simpler to understand IMHO
Thanks
Alessandro
Here the code:
from nevow import appserver, loaders, tags as T
from twisted.application import service, strports
from nevow.livepage import glue, LivePage
from nevow import livepage
class LiveExample(LivePage):
docFactory = loaders.stan(
T.html[
T.head[glue],
T.body[
T.invisible(render=T.directive('choice'))
]
])
def render_choice(self, ctx, data):
def chosen(ctx, choseWhat):
return livepage.set("choosable", \
["Thanks for choosing ", choseWhat])
chooser = livepage.IClientHandle(ctx).transient(chosen)
return T.span(id="choosable")["Choose one:",
T.p(onclick=chooser("one"))["One"],
T.p(onclick=chooser("two"))["Two"]]
site = appserver.NevowSite(LiveExample())
application = service.Application("site")
strports.service("8080", site).setServiceParent(application)
More information about the Twisted-web
mailing list