[Twisted-Python] Example with textbox and html

Steve Lepage slepage at drummonddesigns.com
Thu Jan 15 14:12:37 EST 2004


Hi all,

I begin to program in nevow and I can't bind a textbox with variable
when I use html file to do sql request after. If I use Textbox.tac with
Textbox.html, I don't know how have a textbox and if I use formpost.tac,
I can have textbox binded with variable but I want to work with html
file.
Can people help me, please.

Textbox.tac
import random
from twisted.application import service
from twisted.application import internet
from nevow import renderer
from nevow import appserver
class Textbox(renderer.HTMLRenderer):
    def data_textbox(self, context, data):
        return " DDI Number: "
application = service.Application("Test")
internet.TCPServer(
    8888, 
    appserver.NevowSite(Textbox(templateFile = "Textbox.html"))
#    appserver.NevowSite(Textbox())
).setServiceParent(application)


Textbox.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>First windows with a texbox</title>
	</head>
	<body>
		<ol nevow:data="textbox" nevow:render="string"></ol>	
	</body>
</html>


formpost.tac
from twisted.application import service
from twisted.application import internet
from nevow import appserver
from nevow import renderer
from nevow import tags
from nevow import formless
from nevow import freeform
class IMyForm(formless.TypedInterface):
    foo = formless.Integer()
class FormPage(renderer.Renderer):
    __implements__ = IMyForm, renderer.Renderer.__implements__
    foo = 5
    document = tags.html[
    tags.body[
        "Hello! Here is a form:",
        freeform.configure
    ]
]
application = service.Application("formpost")
internet.TCPServer(
    8888, 
    appserver.NevowSite(
        FormPage()
    )
).setServiceParent(application)





More information about the Twisted-Python mailing list