email = self.get_argument("email")
This is a very simple registration form; however, I would like to implement the deform AJAX registration form as found here:http://deformdemo.repoze.org/ajaxform_redirect/
My
question is, how do I implement the code for the Deform login page with
my tornado "get" and "post" methods? Currently, those methods in the
code above are merely serving html files. How do I successfully include
the deform ajax form code? Is this even possible? If it is possible,
what is the best way to go about implementing the deform code?
Here is the Deform AJAX Redirect Form code:
@view_config(renderer='templates/form.pt', name='ajaxform_redirect')
@demonstrate('AJAX form submission (redirect on success)')
def ajaxform_redirect(self):
class Mapping(colander.Schema):
name = colander.SchemaNode(
colander.String(),
description='Content name')
date = colander.SchemaNode(
colander.Date(),
widget=deform.widget.DatePartsWidget(),
description='Content date')
class Schema(colander.Schema):
number = colander.SchemaNode(
colander.Integer())
mapping = Mapping()
schema = Schema()
options = """
{success:
function (rText, sText, xhr, form) {
var loc = xhr.getResponseHeader('X-Relocate');
if (loc) {
document.location = loc;
};
}
}
"""
def succeed():
location = self.request.resource_url(
self.request.root,
'thanks.html',
route_name='deformdemo',
)
# To appease jquery 1.6+, we need to return something that smells
# like HTML, or we get a "Node cannot be inserted at the
# specified point in the hierarchy" Javascript error. This didn't
# used to be required under JQuery 1.4.
return Response(
'<div>hurr</div>',
headers=[('X-Relocate', location),
('Content-Type', 'text/html')]
)
form = deform.Form(schema, buttons=('submit',), use_ajax=True,
ajax_options=options)
return self.render_form(form, success=succeed)
|