How to use the deform.Form function in deform

To help you get started, we’ve selected a few deform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pylons / deform / deformdemo / app.py View on Github external
    @demonstrate('Sequence of Date Inputs')
    def sequence_of_dateinputs(self):
        import datetime
        from colander import Range
        class Sequence(colander.SequenceSchema):
            date = colander.SchemaNode(
                colander.Date(),
                validator=Range(
                    min=datetime.date(2010, 5, 5),
                    min_err=_('${val} is earlier than earliest date ${min}')
                    )
                )
        class Schema(colander.Schema):
            dates = Sequence()
        schema = Schema()
        form = deform.Form(schema, buttons=('submit',))
        return self.render_form(form)
github Pylons / deform / deformdemo / app.py View on Github external
    @view_config(renderer='templates/form.pt', name='checkedinput')
    @demonstrate('Checked Input Widget')
    def checkedinput(self):
        widget = deform.widget.CheckedInputWidget(
            subject='Email',
            confirm_subject='Confirm Email',
            size=40)
        class Schema(colander.Schema):
            email = colander.SchemaNode(
                colander.String(),
                title='Email Address',
                description='Type your email address and confirm it',
                validator=colander.Email(),
                widget=widget)
        schema = Schema()
        form = deform.Form(schema, buttons=('submit',))
        return self.render_form(form)
github Pylons / deform / deformdemo / app.py View on Github external
    @view_config(renderer='templates/form.pt', name='sequence_of_fileuploads')
    @demonstrate('Sequence of File Upload Widgets')
    def sequence_of_fileuploads(self):
        class Sequence(colander.SequenceSchema):
            upload = colander.SchemaNode(
                deform.FileData(),
                widget=deform.widget.FileUploadWidget(tmpstore)
                )
        class Schema(colander.Schema):
            uploads = Sequence()
        schema = Schema()
        form = deform.Form(schema, buttons=('submit',))
        return self.render_form(form, success=tmpstore.clear)
github ezeep / pyipptool / pyipptool / forms.py View on Github external
release_held_new_jobs_schema,
                      cancel_subscription_schema,
                      )

default_dir = resource_filename('pyipptool', 'templates/')
renderer = deform.template.ZPTRendererFactory((default_dir,))

deform.Form.set_default_renderer(renderer)


cancel_job_form = deform.Form(cancel_job_schema)
release_job_form = deform.Form(release_job_schema)
create_job_form = deform.Form(create_job_schema)
create_job_subscription_form = deform.Form(
    create_job_subscription_schema)
create_printer_subscription_form = deform.Form(
    create_printer_subscription_schema)
cups_add_modify_printer_form = deform.Form(cups_add_modify_printer_schema)
cups_delete_printer_form = deform.Form(cups_delete_printer_schema)
cups_delete_class_form = deform.Form(cups_delete_class_schema)
cups_add_modify_class_form = deform.Form(cups_add_modify_class_schema)
cups_get_classes_form = deform.Form(cups_get_classes_schema)
cups_get_devices_form = deform.Form(cups_get_devices_schema)
cups_get_ppd_form = deform.Form(cups_get_ppd_schema)
cups_get_ppds_form = deform.Form(cups_get_ppds_schema)
cups_get_printers_form = deform.Form(cups_get_printers_schema)
cups_move_job_form = deform.Form(cups_move_job_schema)
cups_reject_jobs_form = deform.Form(cups_reject_jobs_schema)
get_job_attributes_form = deform.Form(get_job_attributes_schema)
get_jobs_form = deform.Form(get_jobs_schema)
get_printer_attributes_form = deform.Form(get_printer_attributes_schema)
get_subscriptions_form = deform.Form(get_subscriptions_schema)
github sacrud / pyramid_sacrud / pyramid_sacrud / form / __init__.py View on Github external
def form_generator(relationships, dbsession, **kwargs):
    schema = SacrudShemaNode(relationships, dbsession, **kwargs)
    submit = deform.Button(name='form.submitted', title="save",
                           css_class='toolbar-button__item')
    return {'form': Form(schema, buttons=(submit,)),
            'js_list': schema.js_list,
            }
github Kotti / Kotti / kotti / views / login.py View on Github external
:param context: Current context
    :type context: :class:`kotti.resources.Content`

    :param request: Current request
    :type request: :class:`kotti.request.Request`

    :param success_msg: Message to display on successful submission handling
    :type success_msg: str or TranslationString

    :result: Redirect response or dictionary passed to the template for
             rendering.
    :rtype: pyramid.httpexceptions.HTTPFound or dict
    """

    form = Form(SetPasswordSchema(), buttons=(Button("submit", _("Set password")),))
    rendered_form = None

    if "submit" in request.POST:
        try:
            appstruct = form.validate(request.POST.items())
        except ValidationFailure as e:
            rendered_form = e.render()
        else:
            token = appstruct["token"]
            email = appstruct["email"]
            user = _find_user(email)
            if (
                user is not None
                and validate_token(user, token)
                and token == user.confirm_token
                and user.active
github indypy / todopyramid / todopyramid / views.py View on Github external
and edit the tasks based on the schema of the form.
        """
        schema = TodoSchema().bind(user_tz=self.user.time_zone)
        options = """
        {success:
          function (rText, sText, xhr, form) {
            deform.processCallbacks();
            deform.focusFirstInput();
            var loc = xhr.getResponseHeader('X-Relocate');
            if (loc) {
              document.location = loc;
            };
           }
        }
        """
        return Form(
            schema,
            buttons=('submit',),
            formid=formid,
            use_ajax=True,
            ajax_options=options,
        )
github VoteIT / voteit.core / voteit / core / views / ticket.py View on Github external
""" After login or registration, redirect back here, where information about the ticket will be displayed,
            and a confirmation that you want to use the ticket for the current user.
            
            While we use a regular deform form, it's not ment to be displayed or handle any validation.
        """
        if not self.request.authenticated_userid:
            raise HTTPForbidden("Direct access to this view for unauthorized users not allowed.")
        email = self.request.GET.get('email', '')
        ticket = self.context.invite_tickets.get(email, None)
        if ticket and ticket.closed != None:
            msg = _("This ticket has already been used.")
            self.flash_messages.add(msg, type = 'danger', auto_destruct = True, require_commit = False)
            return HTTPFound(location = self.request.resource_url(self.context))
        schema = get_content_schemas(self.request.registry)['Meeting']['claim_ticket']()
        schema = schema.bind(context = self.context, request = self.request, view = self)
        form = deform.Form(schema, buttons = (button_add, button_cancel,))
        if self.request.GET.get('claim'):
            controls = self.request.params.items()
            try:
                appstruct = form.validate(controls)
            except deform.ValidationFailure, e:
                msg = _("ticket_validation_fail",
                        default = "Ticket validation failed. Either the "
                        "ticket doesn't exist, was already used or the url used improperly. "
                        "If you need help, please contact the moderator that invited you to this meeting.")
                self.flash_messages.add(msg, type = 'danger', auto_destruct = False, require_commit = False)
                url = self.request.resource_url(self.root)
                return HTTPFound(location = url)
            #Everything in order, claim ticket
            ticket = self.context.invite_tickets[appstruct['email']]
            claim_ticket(ticket, self.request, self.request.authenticated_userid)
            self.flash_messages.add(_(u"You've been granted access to the meeting. Welcome!"))
github ezeep / pyipptool / pyipptool / forms.py View on Github external
create_job_subscription_form = deform.Form(
    create_job_subscription_schema)
create_printer_subscription_form = deform.Form(
    create_printer_subscription_schema)
cups_add_modify_printer_form = deform.Form(cups_add_modify_printer_schema)
cups_delete_printer_form = deform.Form(cups_delete_printer_schema)
cups_delete_class_form = deform.Form(cups_delete_class_schema)
cups_add_modify_class_form = deform.Form(cups_add_modify_class_schema)
cups_get_classes_form = deform.Form(cups_get_classes_schema)
cups_get_devices_form = deform.Form(cups_get_devices_schema)
cups_get_ppd_form = deform.Form(cups_get_ppd_schema)
cups_get_ppds_form = deform.Form(cups_get_ppds_schema)
cups_get_printers_form = deform.Form(cups_get_printers_schema)
cups_move_job_form = deform.Form(cups_move_job_schema)
cups_reject_jobs_form = deform.Form(cups_reject_jobs_schema)
get_job_attributes_form = deform.Form(get_job_attributes_schema)
get_jobs_form = deform.Form(get_jobs_schema)
get_printer_attributes_form = deform.Form(get_printer_attributes_schema)
get_subscriptions_form = deform.Form(get_subscriptions_schema)
get_notifications_form = deform.Form(get_notifications_schema)
pause_printer_form = deform.Form(pause_printer_schema)
print_job_form = deform.Form(print_job_schema)
resume_printer_form = deform.Form(resume_printer_schema)
send_document_form = deform.Form(send_document_schema)
hold_new_jobs_form = deform.Form(hold_new_jobs_schema)
release_held_new_jobs_form = deform.Form(release_held_new_jobs_schema)
cancel_subscription_form = deform.Form(cancel_subscription_schema)
github BirkbeckCTP / annotran / annotran / accounts / views.py View on Github external
def auth_controller_init_patch(self, request):
    """
    Replace the constructor of the h's h.account.views AuthController class - in order to skip the stream loading that
    is not used in the annotran
    :param request: the current request
    :return: None
    """
    form_footer = '<a href="{href}">{text}</a>'.format(
        href=request.route_path('forgot_password'),
        text=_('Forgot your password?'))
    self.request = request
    self.schema = schemas.LoginSchema().bind(request=self.request)
    self.form = deform.Form(self.schema,
                            buttons=(_('Sign in'),),
                            footer=form_footer)
    self.login_redirect = self.request.route_url('index')
    self.logout_redirect = self.request.route_url('index')