Beispiel #1
0
def _listChangeParameter(**parameterKwargs):
    counter = [0]

    def theCallable(repeatableFoo):
        for create in repeatableFoo.create:
            create.setter(u"other thing %d" % (counter[0],))
            counter[0] += 1
        return u"Created %s, edited %s, deleted %s" % (repeatableFoo.create, repeatableFoo.edit, repeatableFoo.delete)

    form = LiveForm(
        theCallable,
        [
            ListChangeParameter(
                u"repeatableFoo",
                [
                    Parameter("foo", TEXT_INPUT, int, "Enter a number"),
                    Parameter("bar", TEXT_INPUT, int, "And another"),
                    ChoiceParameter(
                        "baz", [Option("Value 1", "1", True), Option("Value 2", "2", False)], "Pick something"
                    ),
                ],
                modelObjectDescription=u"Repeatable Foo",
                **parameterKwargs
            )
        ],
    )
    form.jsClass = u"Mantissa.Test.EchoingFormWidget"
    return form
Beispiel #2
0
 def appointmentForm(self, request, tag):
     form = LiveForm(
         self._requestAppointment,
         [Parameter(u"whom", TEXT_INPUT, unicode, u"Whom:",
                    u"The username of the person with whom "
                    u"to create an appointment (user@domain).",
                    None)],
         "Request An Appointment")
     form.setFragmentParent(self)
     return form
Beispiel #3
0
def inputerrors():
    """
    Create a L{LiveForm} which rejects most inputs in order to demonstrate how
    L{InputError} is handled in the browser.
    """
    form = LiveForm(
        lambda theText: None,
        [Parameter(u'theText', TEXT_INPUT, coerce, 'Some Text')],
        u'LiveForm input errors acceptance test',
    )
    return form
Beispiel #4
0
def choiceParameter():
    """
    Create a L{LiveForm} with a L{ChoiceParameter}.
    """
    return LiveForm(lambda **k: unicode(k), [
        ChoiceParameter('choice', [
            Option('Thing 1', 'thing-one', False),
            Option('Thing 2', 'thing-two', True),
            Option('Thing 3', 'thing-three', False)
        ], 'This is a choice between things')
    ])
Beispiel #5
0
    def createPortForm(self, req, tag):
        """
        Create and return a L{LiveForm} for adding a new L{TCPPort} or
        L{SSLPort} to the site store.
        """
        def port(s):
            n = int(s)
            if n < 0 or n > 65535:
                raise ValueError(s)
            return n

        factories = []
        for f in self.store.parent.powerupsFor(IProtocolFactoryFactory):
            factories.append((f.__class__.__name__.decode('ascii'),
                              f,
                              False))

        f = LiveForm(
            self.portConf.createPort,
            [Parameter('portNumber', TEXT_INPUT, port, 'Port Number',
                       'Integer 0 <= n <= 65535 giving the TCP port to bind.'),

             Parameter('interface', TEXT_INPUT, unicode, 'Interface',
                       'Hostname to bind to, or blank for all interfaces.'),

             Parameter('ssl', CHECKBOX_INPUT, bool, 'SSL',
                       'Select to indicate port should use SSL.'),

             # Text area?  File upload?  What?
             Parameter('certPath', TEXT_INPUT, unicode, 'Certificate Path',
                       'Path to a certificate file on the server, if SSL is to be used.'),

             ChoiceParameter('factory', factories, 'Protocol Factory',
                             'Which pre-existing protocol factory to associate with this port.')])
        f.setFragmentParent(self)
        # f.docFactory = webtheme.getLoader(f.fragmentName)
        return tag[f]
Beispiel #6
0
def _listChangeParameter(**parameterKwargs):
    counter = [0]

    def theCallable(repeatableFoo):
        for create in repeatableFoo.create:
            create.setter(u'other thing %d' % (counter[0], ))
            counter[0] += 1
        return u'Created %s, edited %s, deleted %s' % (
            repeatableFoo.create, repeatableFoo.edit, repeatableFoo.delete)

    form = LiveForm(theCallable, [
        ListChangeParameter(u'repeatableFoo', [
            Parameter('foo', TEXT_INPUT, int, 'Enter a number'),
            Parameter('bar', TEXT_INPUT, int, 'And another'),
            ChoiceParameter(
                'baz',
                [Option('Value 1', '1', True),
                 Option('Value 2', '2', False)], 'Pick something')
        ],
                            modelObjectDescription=u'Repeatable Foo',
                            **parameterKwargs)
    ])
    form.jsClass = u'Mantissa.Test.EchoingFormWidget'
    return form