from nagare.namespaces import xhtml
l = ['the', 'mandatory', 'hello', 'world']
h = xhtml.Renderer()
with h.div(id='content'):
with h.ul:
h << [h.li(element) for element in l]
print h.root.write_htmlstring()
Or a (X)HTML template can have nodes annotated with a 'meld:id=<id>'
attribut. They are then retreived and manipulated in Python. from nagare import presentation
# A pure python Counter class
class Counter:
def __init__(self, v=0):
self.v = v
def increase(self):
self.v += 1
def decrease(self):
self.v -= 1
# Default HTML view on the Counter class
@presentation.render_for(Counter)
def render(self, h, *args):
return h.div(
h.p('Value: ', self.v),
h.a('++').action(self.increase),
' | ',
h.a('--').action(self.decrease)
)
Python Stackless is used to take continuations and also to serialize all the states, which can be stored, by configuration, in memory or to an external Memcached server. With the later setting, all the continuations can freely migrate across the machines of a cluster.