[Twisted-Python] nuvow webform example?
I have another question about the docs in nuvow webform. I'm following
the tutorial for nevow and I want to create a dynamic form with model.
http://www.divmod.org/Home/Projects/Nevow/index.html
I see an example of the webform, but it doesn't quite work:
class WebForm(rend.Page):
# document = rend.stan( # this should be changed to:
docFactory = loaders.stan(
tags.html[
tags.body[
h1["Here is the form:"],
webform.renderForms('original')
]
])
resource = WebForm(Implementation())
I'm not sure I quite understand why 'original' goes there, but in any
case, I don't get any output from this. Is there something else that
needs to be fixed with this example?
On Fri, 24 Dec 2004 17:23:15 -0500, William Waites
On Fri, Dec 24, 2004 at 01:50:46PM -0800, Alan Ezust wrote:
Ah, thanks... the wait() did the trick.
As it turned out, all I was doing was a little test apparently creating and calling renderstring() immediately afterwards is a little too soon for python to handle, in this example...
Careful though -- wait is only appropriate to use in trivial examples. in fact it is only used in the test suite. It does some things that are not really allowed. Take a look at the implementation of wait.
It is really much better to schedule a callback -- this is the meaning of "you don't call twisted, twisted calls you".
Good luck, -w
-- ... a poem about a haircut! But lofty, noble, tragic, timeless, full of love, treachery, retribution, quiet heroism in the face of certain doom! Six lines, cleverly rhymed, and every word beginning with the letter s!
oops. That last message was not clear at all. Let me try again... I'm following the tutorial. I defined classes class ISimpleMethod(TypedInterface): class Implementation(object): as shown in the tutorial. Then I fixed up the webform, and here is my version: class WebForm(rend.Page): docFactory = loaders.stan( tags.html[ tags.body[ tags.h1["Here is the form:"], webform.renderForms('original') ]]) And here is a handler that is supposed to render the form. def handler(req): req.content_type = "text/html" req.send_http_header() # this was the greeting example - works great. page = SearchPage("My name is Joe") page.renderString().addCallback(req.write) # webform example - attempt to display. # I see "here is the form" but nothing else resource = WebForm(Implementation()) resource.renderString().addCallback(req.write) return apache.OK
participants (1)
-
Alan Ezust