[Twisted-web] Rendering error messages

Michael Wilson michael.wilson at gmail.com
Tue Dec 14 17:54:54 MST 2004

I have a form where the inputs various values, which I then check for
validity. If there are errors, I'd like to re-display the form, with

>From the examples, I see how to use pasting to get the error into the form:

            <td>School name:</td>
            <td><input type="text" name="name" /></td>
            <td><nevow:slot name="nameError">error</nevow:slot></td>

	def render_aPasting(self, context, data):
			context.tag.fillSlots('nameError', self.nameError)


That works great. The problem is, I initialize self.nameError in __init__:

self.nameError = ''

And then set it in the formless autocall if there is an error:


		if self.schoolDb.exists( name ):
			self.nameError	= 'School already exists!'

The problem is that when the page is re-rendered, __init__ is being
called again, which means the errors get cleared.

My instinct is that maybe I should use session variables, but before I
got an do that I wanted to make sure there wasn't another, more
correct way to do this.


More information about the Twisted-web mailing list