How to use the formencode.validators.UnicodeString function in FormEncode

To help you get started, we’ve selected a few FormEncode 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 the-virtual-brain / tvb-framework / tvb / interfaces / web / controllers / project / dti_pipeline_controller.py View on Github external
"""
    Validate for Import Connectivity Form
    """
    server_ip = validators.IPAddress(not_empty=True)
    username = validators.UnicodeString(not_empty=True)  
    password = validators.UnicodeString()
    threads_number = validators.Number()
    
    dti_scans = FileUploadValidator()
    
    subject_name = validators.UnicodeString()
    subject_sex = validators.OneOf(['Any', 'Male', 'Female'])  
    subject_age = validators.Number()
    subject_race = validators.UnicodeString()
    subject_nationality = validators.UnicodeString()
    subject_education = validators.UnicodeString()
    subject_health = validators.UnicodeString()
github aptise / peter_sslers / peter_sslers / web / lib / forms.py View on Github external
class Form_Domain_search(_Form_Schema_Base):
    domain = UnicodeString(not_empty=True)


class Form_Domain_AcmeDnsServer_new(_Form_Schema_Base):
    acme_dns_server_id = Int(not_empty=True)


class Form_PrivateKey_new__autogenerate(_Form_Schema_Base):
    bits = OneOf(("4096",), not_empty=True)


class Form_PrivateKey_new__full(_Form_Schema_Base):
    private_key = UnicodeString(not_empty=False, if_missing=None)
    private_key_file_pem = FieldStorageUploadConverter(not_empty=False, if_missing=None)
    chained_validators = [
        OnlyOneOf(("private_key", "private_key_file_pem"), not_empty=True)
    ]


class Form_PrivateKey_new__file(_Form_Schema_Base):
    private_key_file_pem = FieldStorageUploadConverter(not_empty=True)


class Form_PrivateKey_mark(_Form_Schema_Base):
    action = OneOf(("compromised", "active", "inactive",), not_empty=True)


class Form_QueueCertificate_new_freeform(_form_AcmeAccount_PrivateKey_reuse):
    # this is the `private_key_cycle` of the AcmeOrder renewals
github apache / allura / Allura / allura / lib / widgets / forms.py View on Github external
V.OneOfValidator(['Male', 'Female', 'Unknown', 'Other']),
                    fev.UnicodeString(not_empty=True))),
            ew.SingleSelectField(
                name='country',
                label='Country of residence',
                validator=V.MapValidator(country_names, not_empty=False),
                options=[ew.Option(py_value=" ", label=" -- Unknown -- ", selected=False)] +
                        [ew.Option(py_value=c, label=n, selected=False)
                         for c, n in sorted(country_names.items(),
                                            key=lambda (k, v): v)],
                attrs={'onchange': 'selectTimezone(this.value)'}),
            ew.TextField(
                name='city',
                label='City of residence',
                attrs=dict(value=None),
                validator=fev.UnicodeString(not_empty=False)),
            ew.SingleSelectField(
                name='timezone',
                label='Timezone',
                attrs={'id': 'tz'},
                validator=V.OneOfValidator(common_timezones, not_empty=False),
                options=[ew.Option(py_value=" ", label=" -- Unknown -- ")] +
                        [ew.Option(py_value=n, label=n)
                         for n in sorted(common_timezones)])
        ]
        if asbool(tg.config.get('auth.allow_birth_date', True)):
            list_of_fields[1:1] = self.birth_date_fields

        return list_of_fields
github apache / allura / ForgeChat / forgechat / main.py View on Github external
    @validate(dict(q=validators.UnicodeString(if_empty=None),
                   project=validators.StringBool(if_empty=False)))
    def search(self, q=None, project=None, limit=None, page=0, **kw):
        c.search_results = SearchResults()
        c.help_modal = SearchHelp(comments=False, history=False,
                                  fields={'sender_t': 'username',
                                          'text': '"Message text"',
                                          })
        search_params = kw
        search_params.update({
            'q': q or '',
            'project': project,
            'limit': limit,
            'page': page,
            'allowed_types': ['Chat Message'],
        })
        d = search_app(**search_params)
github apache / allura / ForgeImporters / forgeimporters / google / code.py View on Github external
'git': 'https://code.google.com{hosted_domain_prefix}/p/{project_name}/',
    'hg': 'https://code.google.com{hosted_domain_prefix}/p/{project_name}/',
}


def get_repo_url(project_name, type_):
    hosted_domain_prefix, project_name = split_project_name(project_name)
    if hosted_domain_prefix and type_ == 'svn':
        type_ = 'svn-hosted'
    return REPO_URLS[type_].format(project_name=project_name,
                                   hosted_domain_prefix=hosted_domain_prefix)


class GoogleRepoImportForm(fe.schema.Schema):
    gc_project_name = GoogleCodeProjectNameValidator()
    mount_point = fev.UnicodeString()
    mount_label = fev.UnicodeString()

    def __init__(self, *args):
        pass

    def _to_python(self, value, state):
        value = super(self.__class__, self)._to_python(value, state)

        gc_project_name = value['gc_project_name']
        mount_point = value['mount_point']
        try:
            repo_type = GoogleCodeProjectExtractor(
                gc_project_name).get_repo_type()
        except urllib2.HTTPError as e:
            if e.code == 404:
                msg = 'No such project'
github apache / allura / Allura / allura / lib / widgets / forms.py View on Github external
if d["categoryid"]:
            d["categoryid"] = int(d['categoryid'])
        return d


class AddTroveCategoryForm(ForgeForm):
    defaults = dict(ForgeForm.defaults)

    class fields(ew_core.NameList):
        uppercategory_id = ew.HiddenField(
            attrs={'value': ''},
            show_errors=False)
        categoryname = ew.TextField(
            label="Category name",
            attrs={},
            validator=fev.UnicodeString(not_empty=True))
        shortname = ew.TextField(
            label="Short name",
            validator=fev.UnicodeString(),
            attrs={'placeholder': 'optional; unique identifier'})

    def display(self, **kw):
        upper_category = kw.get('uppercategory_id', 0)

        self.fields['uppercategory_id'].attrs['value'] = upper_category
        return super(ForgeForm, self).display(**kw)

    @ew_core.core.validator
    def to_python(self, kw, state):
        d = super(AddTroveCategoryForm, self).to_python(kw, state)
        d["uppercategory_id"] = kw.get('uppercategory_id', 0)
        return d
github apache / allura / ForgeTracker / forgetracker / widgets / bin_form.py View on Github external
class BinForm(ew.SimpleForm):
    template = 'jinja:forgetracker:templates/tracker_widgets/bin_form.html'
    defaults = dict(
        ew.SimpleForm.defaults,
        submit_text="Save Bin")

    class hidden_fields(ew.NameList):
        _id = jinja2_ew.HiddenField(
            validator=V.Ming(model.Bin), if_missing=None)

    class fields(ew.NameList):
        summary = jinja2_ew.TextField(
            label='Bin Name',
            validator=fev.UnicodeString(not_empty=True))
        terms = jinja2_ew.TextField(
            label='Search Terms',
            validator=fev.UnicodeString(not_empty=True))
github aptise / peter_sslers / peter_sslers / web / lib / forms.py View on Github external
class _form_PrivateKey_reuse(_form_PrivateKey_core):
    private_key_option = OneOf(model_utils.PrivateKey_options_b, not_empty=True)
    private_key_reuse = UnicodeString(not_empty=False, if_missing=None)


class _form_AcmeAccount_PrivateKey_core(_Form_Schema_Base):
    """this is a mix of two forms, because FormEncode doesn't support multiple class inheritance
    """

    account_key_option = OneOf(
        ("account_key_global_default", "account_key_existing", "account_key_file"),
        not_empty=True,
    )
    account_key_global_default = UnicodeString(not_empty=False, if_missing=None)
    account_key_existing = UnicodeString(not_empty=False, if_missing=None)

    account__contact = Email(not_empty=False, if_missing=None)  # required if key_pem

    # this is the `private_key_cycle` of the AcmeAccount
    account__private_key_cycle = OneOf(
        model_utils.PrivateKeyCycle._options_AcmeAccount_private_key_cycle,
        not_empty=True,
    )

    # these are via Form_AcmeAccount_new__file
    account_key_file_pem = FieldStorageUploadConverter(not_empty=False, if_missing=None)
    account_key_file_le_meta = FieldStorageUploadConverter(
        not_empty=False, if_missing=None
    )
    account_key_file_le_pkey = FieldStorageUploadConverter(
        not_empty=False, if_missing=None
github apache / allura / ForgeImporters / forgeimporters / trac / wiki.py View on Github external
from allura.controllers import BaseController
from allura.lib.decorators import require_post
from allura.model import ApiTicket

from forgeimporters.base import ToolImporter

from forgewiki.scripts.wiki_from_trac.extractors import WikiExporter
from forgewiki.scripts.wiki_from_trac.loaders import load_data
from forgewiki.scripts.wiki_from_trac.wiki_from_trac import WikiFromTrac
from forgewiki.wiki_main import ForgeWikiApp


class TracWikiImportSchema(fe.Schema):
    trac_url = fev.URL(not_empty=True)
    mount_point = fev.UnicodeString()
    mount_label = fev.UnicodeString()


class TracWikiImportController(BaseController):
    @with_trailing_slash
    @expose('jinja:forgeimporters.trac:templates/wiki/index.html')
    def index(self, **kw):
        return {}

    @without_trailing_slash
    @expose()
    @require_post()
    @validate(TracWikiImportSchema(), error_handler=index)
    def create(self, trac_url, mount_point, mount_label, **kw):
        app = TracWikiImporter.import_tool(c.project,
                mount_point=mount_point,
github apache / allura / ForgeWiki / forgewiki / wiki_main.py View on Github external
    @validate(dict(q=validators.UnicodeString(if_empty=None),
                   history=validators.StringBool(if_empty=False),
                   search_comments=validators.StringBool(if_empty=False),
                   project=validators.StringBool(if_empty=False)))
    def search(self, q=None, history=None, search_comments=None, project=None, limit=None, page=0, **kw):
        'local wiki search'
        c.search_results = W.search_results
        c.help_modal = W.help_modal
        search_params = kw
        search_params.update({
            'q': q or '',
            'history': history,
            'search_comments': search_comments,
            'project': project,
            'limit': limit,
            'page': page,
            'allowed_types': ['WikiPage', 'WikiPage Snapshot'],