[Twisted-web] MVC on Nevow
Jose Figueras
twisted-web@twistedmatrix.com
11 Mar 2004 09:25:47 +0100
Hi all
I'm developing one Nevow webapp proto before the big one webapp (you
know, python packages, n-tier, MVC, html documents, pictures, stylesheets, etc...).
What must I do to develop a Nevow MVC app ?
Suppose this directory structure:
[PYTHONPATH]/a/b/c/model/
[PYTHONPATH]/a/b/c/view/
[PYTHONPATH]/a/b/c/controller/
this TAC file:
from twisted.application import service
from twisted.application import internet
from nevow import appserver
from a.b.c.controller import main
application = service.Application("proto")
internet.TCPServer(
8080,
appserver.NevowSite(
main.MainPageRenderer()
)
).setServiceParent(application)
and this Nevow resource (on [PYTHONPATH]/a/b/c/controller/main.py):
import os
from nevow import rend
class MainPageRenderer(rend.Page):
docFactory = rend.htmlfile(os.path.join(os.path.split(__file__)[0],
"../view/main.html"))
1. How must I define this 'NevowSite' and <a> tags on this HTML file
(remember, [a_very_big_path]/a/b/c/view/main.html) to point other
static HTML documents (on, p.e.
[a_very_big_path]/a/b/c/view/second.html) ?
2. and what about dynamic pages created by 'rend.Page' instances (on,
p.e. [PYTHONPATH]/a/b/c/controller/third.py) ?
3. Last, how can I implement (and use) one 'controller' in this
situation ?
Jose