コード例 #1
0
    def rend(self, context, data):
        defaults = context.locate(iformless.IFormDefaults)
        value = defaults.getDefault(context.key, context)
        context.remember(data.typedValue, iformless.ITyped)

        if data.typedValue.getAttribute('immutable'):
            inp = span(id=keyToXMLID(context.key))[value]
        else:
            ##value may be a deferred; make sure to wait on it properly before calling self.input
            ## TODO: If flattening this results in an empty string, return an empty string
            inp = invisible(render=lambda c, value: self.input(
                context, invisible(), data, data.name, value),
                            data=value)

        if data.typedValue.getAttribute(
                'hidden') or data.typedValue.getAttribute('compact'):
            return inp

        context.fillSlots('label', data.label)
        context.fillSlots('name', data.name)
        context.fillSlots('input', inp)
        context.fillSlots('error', getError(context))
        context.fillSlots('description', data.description)
        context.fillSlots('id', keyToXMLID(context.key))
        context.fillSlots('value', value)

        return context.tag
コード例 #2
0
ファイル: webform.py プロジェクト: StetHD/nevow
    def rend(self, context, data):
        defaults = context.locate(iformless.IFormDefaults)
        value = defaults.getDefault(context.key, context)
        context.remember(data.typedValue, iformless.ITyped)

        if data.typedValue.getAttribute('immutable'):
            inp = tags.span(id=keyToXMLID(context.key))[value]
        else:
            ##value may be a deferred; make sure to wait on it properly before calling self.input
            ## TODO: If flattening this results in an empty string, return an empty string
            inp = tags.invisible(
                render=lambda c, value: self.input( context, tags.invisible(), data, data.name, value ),
                data=value)

        if data.typedValue.getAttribute('hidden') or data.typedValue.getAttribute('compact'):
            return inp

        context.fillSlots( 'label', data.label )
        context.fillSlots( 'name', data.name )
        context.fillSlots( 'input', inp )
        context.fillSlots( 'error', getError(context) )
        context.fillSlots( 'description', data.description )
        context.fillSlots( 'id', keyToXMLID(context.key) )
        context.fillSlots( 'value', value )

        return context.tag
コード例 #3
0
    def rend(self, context, data):
        context.remember(data, iformless.IBinding)

        from formless import configurable as conf

        configurable = conf.GroupConfigurable(data.boundTo,
                                              data.typedValue.iface)
        context.remember(configurable, iformless.IConfigurable)

        bindingNames = configurable.getBindingNames(context)

        def generateBindings():
            for name in bindingNames:
                bnd = configurable.getBinding(context, name)
                renderer = iformless.IBindingRenderer(bnd,
                                                      defaultBindingRenderer)
                renderer.isGrouped = True
                renderer.needsSkin = True
                yield invisible(data=bnd, render=renderer, key=name)

        return getError(context), form(
            id=keyToXMLID(context.key),
            enctype="multipart/form-data",
            action=calculatePostURL(context, data),
            method="post",
            **{'accept-charset': 'utf-8'
               })[fieldset[legend(_class="freeform-form-label")[data.label],
                           input(type='hidden', name='_charset_'),
                           generateBindings(),
                           input(type="submit")]]
コード例 #4
0
ファイル: webform.py プロジェクト: StetHD/nevow
    def rend(self, context, data):
        context.remember(data, iformless.IBinding)

        from formless import configurable as conf

        configurable = conf.GroupConfigurable(data.boundTo, data.typedValue.iface)
        context.remember(configurable, iformless.IConfigurable)

        bindingNames = configurable.getBindingNames(context)

        def generateBindings():
            for name in bindingNames:
                bnd = configurable.getBinding(context, name)
                renderer = iformless.IBindingRenderer(bnd, defaultBindingRenderer)
                renderer.isGrouped = True
                renderer.needsSkin = True
                yield tags.invisible(
                    data=bnd,
                    render=renderer,
                    key=name)

        return getError(context), tags.form(
            id=keyToXMLID(context.key),
            enctype="multipart/form-data",
            action=calculatePostURL(context, data),
            method="post",
            **{'accept-charset':'utf-8'})[
                tags.fieldset[
                    tags.legend(_class="freeform-form-label")[data.label],
                    tags.input(type='hidden', name='_charset_'),
                    generateBindings(),
                    tags.input(type="submit")]]
コード例 #5
0
ファイル: webform.py プロジェクト: StetHD/nevow
 def input(self, context, slot, data, name, value):
     if data.typedValue.getAttribute('hidden'):
         T="hidden"
     else:
         T="text"
     return slot[
         tags.input(id=keyToXMLID(context.key), type=T, name=name, value=value,
               _class='freeform-input-%s' % T)]
コード例 #6
0
 def input(self, context, slot, data, name, value):
     if data.typedValue.getAttribute('hidden'):
         T="hidden"
     else:
         T="text"
     return slot[
         tags.input(id=keyToXMLID(context.key), type=T, name=name, value=value,
               _class='freeform-input-%s' % T)]
コード例 #7
0
 def rend(self, context, data):
     defaults = context.locate(iformless.IFormDefaults)
     value = defaults.getDefault(context.key, context)
     context.remember(data.typedValue, iformless.ITyped)
     if data.typedValue.getAttribute('immutable'):
         inp = span(id=keyToXMLID(context.key))[value]
     else:
         inp = invisible(
             render=lambda c, value: self.input( context, invisible(), data, data.name, value ),
             data=value)
     if data.typedValue.getAttribute('hidden') or data.typedValue.getAttribute('compact'):
         return inp
     context.fillSlots( 'label', data.label )
     context.fillSlots( 'name', data.name )
     context.fillSlots( 'input', inp )
     context.fillSlots( 'error', getError(context) )
     context.fillSlots( 'description', data.description )
     context.fillSlots( 'id', keyToXMLID(context.key) )
     context.fillSlots( 'value', value )
     return context.tag
コード例 #8
0
 def input(self, context, slot, data, name, value):
     return [
         input(id=keyToXMLID(context.key),
               name=name,
               type="password",
               _class="freeform-input-password"),
         " Again ",
         input(name="%s____2" % name,
               type="password",
               _class="freeform-input-password"),
     ]
コード例 #9
0
ファイル: webform.py プロジェクト: StetHD/nevow
    def input(self, context, slot, data, name, value):
        ## The only difference here is the "checked" attribute; the value is still the same because
        ## we want true to be passed to the server when the checkbox is checked and the form
        ## is posted.
        node = tags.input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
        if value:
            node(checked="checked")

        # HTML forms are so weak. If the checkbox is not checked, no value at all will be
        # in request.args with the name data.name. So let's force the value False to always
        # be in request.args[data.name]. If the checkbox is checked, the value True will
        # be first, and we will find that.
        return slot[node, tags.input(type="hidden", name=name, value="False")]
コード例 #10
0
    def input(self, context, slot, data, name, value):
        ## The only difference here is the "checked" attribute; the value is still the same because
        ## we want true to be passed to the server when the checkbox is checked and the form
        ## is posted.
        node = tags.input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
        if value:
            node(checked="checked")

        # HTML forms are so weak. If the checkbox is not checked, no value at all will be
        # in request.args with the name data.name. So let's force the value False to always
        # be in request.args[data.name]. If the checkbox is checked, the value True will
        # be first, and we will find that.
        return slot[node, tags.input(type="hidden", name=name, value="False")]
コード例 #11
0
ファイル: webform.py プロジェクト: StetHD/nevow
 def rend(self, context, data):
     return tags.input(id=keyToXMLID(context.key), type='submit', value=data.label, name=data.name, class_="freeform-button")
コード例 #12
0
ファイル: webform.py プロジェクト: StetHD/nevow
 def fillForm(self, context, data):
     context.fillSlots( 'form-id', keyToXMLID(context.key) )
     context.fillSlots( 'form-action', calculatePostURL(context, data) )
     context.fillSlots( 'form-name', data.name )
     context.fillSlots( 'form-error', getError(context) )
コード例 #13
0
 def input(self, context, slot, data, name, value):
     node = input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
     if value:
         node(checked="checked")
     return slot[node, input(type="hidden", name=name, value="False")]
コード例 #14
0
ファイル: webform.py プロジェクト: StetHD/nevow
 def input(self, context, slot, data, name, value):
     return [
         tags.input(id=keyToXMLID(context.key), name=name, type="password", _class="freeform-input-password"),
         " Again ",
         tags.input(name="%s____2" % name, type="password", _class="freeform-input-password"),
     ]
コード例 #15
0
 def input(self, context, slot, data, name, value):
     return slot[input(id=keyToXMLID(context.key),
                       type="file",
                       name=name,
                       _class='freeform-input-file')]
コード例 #16
0
 def input(self, context, slot, data, name, value):
     return slot[textarea(id=keyToXMLID(context.key),
                          name=name,
                          _class="freeform-textarea",
                          rows=8,
                          cols=40)[value or '']]
コード例 #17
0
 def input(self, context, slot, data, name, value):
     return slot[input(id=keyToXMLID(context.key),
                       type='password',
                       name=name,
                       _class='freeform-input-password')]
コード例 #18
0
 def input(self, context, slot, data, name, value):
     return slot[input(id=keyToXMLID(context.key), type="file", name=name,
                       _class='freeform-input-file')]
コード例 #19
0
ファイル: webform.py プロジェクト: perkinslr/nevow-py3
 def fillForm(self, context, data):
     context.fillSlots("form-id", keyToXMLID(context.key))
     context.fillSlots("form-action", calculatePostURL(context, data))
     context.fillSlots("form-name", data.name)
     context.fillSlots("form-error", getError(context))
コード例 #20
0
ファイル: webform.py プロジェクト: StetHD/nevow
 def input(self, context, slot, data, name, value):
     return slot[
         tags.input(id=keyToXMLID(context.key), type='password', name=name,
               _class='freeform-input-password')]
コード例 #21
0
 def fillForm(self, context, data):
     context.fillSlots('form-id', keyToXMLID(context.key))
     context.fillSlots('form-action', calculatePostURL(context, data))
     context.fillSlots('form-name', data.name)
     context.fillSlots('form-error', getError(context))
コード例 #22
0
ファイル: webform.py プロジェクト: StetHD/nevow
 def input(self, context, slot, data, name, value):
     return slot[
         tags.textarea(id=keyToXMLID(context.key), name=name, _class="freeform-textarea", rows=8, cols=40)[
             value or '']]
コード例 #23
0
 def rend(self, context, data):
     return input(id=keyToXMLID(context.key),
                  type='submit',
                  value=data.label,
                  name=data.name,
                  class_="freeform-button")