Skip to content

Instantly share code, notes, and snippets.

@JDeuce
Created May 1, 2012 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JDeuce/2571326 to your computer and use it in GitHub Desktop.
Save JDeuce/2571326 to your computer and use it in GitHub Desktop.
test case for integer values with radio choice widget
from pyramid.config import Configurator
from pyramid.view import view_config
from colander import Schema, SchemaNode, Int, String
from deform.widget import RadioChoiceWidget
from deform.form import Form
import waitress
class TestSchema(Schema):
string_field = SchemaNode(
String(),
widget=RadioChoiceWidget(values=(('0','zero'),('1','one')))
)
int_field = SchemaNode(
Int(),
widget=RadioChoiceWidget(values=((0, 'zero'),(1,'one')))
)
@view_config(route_name='home')
def test_radio_form(request):
form = Form(TestSchema(), buttons=('submit',))
from pyramid.response import Response
return Response(form.render({'string_field': '0', 'int_field': 0}))
if __name__ == "__main__":
config = Configurator()
config.add_route('home', '/')
config.scan()
app = config.make_wsgi_app()
waitress.serve(app, host='0.0.0.0', port='6444')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment