Re: Athena and Forms

[email protected] Fri, 09 Mar 2007 03:36:37 -0000
Newsgroups gmane.comp.python.quotient.dev
Message-ID <20070309033637.7769.83340160.divmod.xquotient.295@joule.divmod.com>
On 8 Mar, 08:12 pm, [email protected] wrote:
>The application I am building will require the responsiveness of AJAX 
>and happily Athena fills that gap nicely. However I will also need 
>good forms support (...)

The reason that Athena doesn't have much in the way of forms support is 
that it doesn't need any.

You mentioned needing the responsiveness of "AJAX".  If you want your 
"forms" to be responsive, they shouldn't be forms at all, but remote 
calls with athena.

For an example of how this can work, you can have a look here:

http://divmod.org/trac/browser/trunk/Mantissa/xmantissa/js/Mantissa/LiveForm.js

and here:

http://divmod.org/trac/browser/trunk/Mantissa/xmantissa/js/Mantissa/Validate.js

It's very simple to pick up a few values from form fields in a DOM and 
then call a method on the server with those values.  Please keep in mind 
that the stuff in Mantissa is somewhat Mantissa specific, and not 
everyone is happy with the API that it provides, so I'm not saying that 
you should try to *use* LiveForm; it is simply an example of how one 
might extract values from form fields and pass them to the server.  Your 
own application will probably have its own assumptions about client-side 
validation and synchronization with the server.

If your application already relies on Athena, you won't lose anything by 
doing things this way, and you will gain a huge amount of 
responsiveness.  If you want to support browsers that can't run Athena, 
you can always have a form representation in your application which 
would work with both plain-vanilla pages with server-side validation and 
fancy Athena stuff on the client and keep separate UIs for those two 
cases.

In my experience it has always been easier to write that layer custom 
for each application than shoehorn each application into a generic forms 
library and learn about all the hooks for customizing it.
>While I'm at it - does anybody know if Nevow works on top of Twisted 
>2.5?

Yes.
>Any plans to support Twisted Web2?

Yes, but they require effort.  It does not support web2 now, and there 
is pretty much nobody working on it because first web2 has to be 
finished.

At the very least, this list needs to be emptied out:

http://twistedmatrix.com/trac/query?status=new&status=assigned&status=reopened&milestone=Web2 
-Gold-Master

and we could definitely use some help with that.  Please have a look and 
consider contributing some patches :).