4 karma · joined Sep 26, 2008 (18y ago) · 7 submissions
comment 14y ago · link · parent
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.
comment 15y ago · link · parent
comment 17y ago · link · parent
comment 17y ago · link · parent
comment 17y ago · link · parent
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.In both cases, one of the main goal is not to reinvent a new syntax / templating language but to use normal Python with all its power. Also the generated (X)HTML is always well-formed.
comment 17y ago · link · parent
comment 18y ago · link · parent
Launched with : nagare-admin serve-module counter.py:Counter counter ===============================================
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)
)