from twisted.web.woven import model, view, page, interfaces class V(view.View): template = '''
It is a totally awesome view! THIS TEXT SHOULD GO AWAY
''' class Va(view.View): template = '''
This is an adapter-magical view!
''' class Ma(model.AttributeModel): q = "And this is a string gotten from an adapter-magic model." class A: pass from twisted.python.components import registerAdapter view.registerViewForModel(Va, Ma) registerAdapter(Ma, A, interfaces.IModel) class P(page.Page): template = ''' P Demo of both model and view specified:
THIS TEXT IS INVISIBLE
Demo of a model which gets its view through adapter magic:
''' def wmfactory_m(self, request): m = model.AttributeModel() m.s = 'it is a string' return m def wvfactory_v(self, request, node, model): return V(model) def wmfactory_a(self): return A()