API Reference

class pyramid_uniform.Form(request, schema, method='POST')[source]
assert_valid(**kw)[source]
bind(obj)[source]
errors_for(field)[source]
is_error(field)[source]
method_allowed[source]

Is the method that was used to submit this form allowed?.

If this form doesn’t have a request method set (i.e., if it was explicitly set to None), any method is valid. Otherwise, the method of the form submission must match the method required by this form.

validate(skip_csrf=False, assert_valid=False)[source]

Validate a form submission.

When assert_valid is False (the default), a bool will be returned to indicate whether the form was valid. (Note: this isn’t strictly true–a missing or bad CSRF token will result in a immediate 400 Bad Request response).

When assert_valid is True, certain conditions will be assert``ed. When an assertion fails, the resulting ``AssertionError will cause an internal server error, which will in turn cause an error email to be sent out.

validate_csrf(params=None)[source]
exception pyramid_uniform.FormError(*args, **kw)[source]

Superclass for form-related errors.

exception pyramid_uniform.FormInvalid(*args, **kw)[source]

Raised when form data is used but the form is not valid.

message = 'Form is invalid'
exception pyramid_uniform.FormNotValidatedError(*args, **kw)[source]

Raised when form data is used before form has been validated: for example, when form.bind() is called.

message = 'Form has not been validated; call validate() first'
class pyramid_uniform.FormRenderer(form, csrf_field='_authentication_token', id_prefix=None)[source]
begin(url=None, **attrs)[source]
csrf(name=None)[source]
csrf_token(name=None)[source]
end()[source]
class pyramid_uniform.Renderer(data, errors, id_prefix=None)[source]
checkbox(name, value='1', checked=False, label=None, id=None, **attrs)[source]
errorlist(name)[source]
errors_for(name)[source]
file(name, value=None, id=None, **attrs)[source]
hidden(name, value=None, id=None, **attrs)[source]
is_error(name)[source]
password(name, value=None, id=None, **attrs)[source]
radio(name, value=None, checked=False, label=None, **attrs)[source]
select(name, selected_values, options, id=None, **attrs)[source]
submit(name, value=None, id=None, **attrs)[source]
text(name, value=None, id=None, **attrs)[source]
textarea(name, content='', id=None, **attrs)[source]
value(name, default=None)[source]
class pyramid_uniform.State(request)[source]

A relatively simple state object for FormEncode to use, with a reference to the request being validated.