def new_form(self): form = Form(self.web_fixture.view, 'some_form') event = Event(label='click me', action=Action(self.action)) event.bind('an_event', None) form.define_event_handler(event, target=self.target) form.add_child(ButtonInput(form, event)) return form
def validation_of_event_arguments(fixture): """Buttons cannot be created for Events with invalid default arguments.""" class ModelObject(object): @exposed def events(self, events): events.an_event = Event(label='Click me', argument=Field(required=True)) model_object = ModelObject() form = Form(fixture.view, 'test') form.define_event_handler(model_object.events.an_event) with expected(ProgrammerError): ButtonInput(form, model_object.events.an_event) with expected(NoException): ButtonInput( form, model_object.events.an_event.with_arguments(argument='something'))