How to use the formencode.validators.StringBool 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 apache / allura / ForgeActivity / forgeactivity / widgets / follow.py View on Github external
import ew as ew_core
import ew.jinja2_ew as ew


class FollowToggle(ew.SimpleForm):
    template = 'jinja:forgeactivity:templates/widgets/follow.html'
    defaults = dict(
        ew.SimpleForm.defaults,
        thing='project',
        action='follow',
        action_label='follow',
        icon='star',
        following=False)

    class fields(ew_core.NameList):
        follow = ew.HiddenField(validator=fev.StringBool())

    def resources(self):
        yield ew.JSLink('activity_js/follow.js')

    def prepare_context(self, context):
        default_context = super(FollowToggle, self).prepare_context({})
        if c.project.is_user_project:
            default_context.update(
                thing=c.project.user_project_of.display_name,
            )
        else:
            default_context.update(thing=c.project.name)
        default_context.update(context)
        return default_context

    def success_message(self, following):
github hep-gc / repoman / server / repoman / repoman / model / form.py View on Github external
filter_extra_fields = True

    user_name = formencode.validators.String(if_missing=None)

    name = formencode.validators.String(not_empty=True)
    description = formencode.validators.String(if_missing=None)

    os_variant = formencode.validators.String(if_missing=None)
    os_type = formencode.validators.String(if_missing=None)
    os_arch = formencode.validators.String(if_missing=None)
    hypervisor = formencode.validators.String(if_missing=None)

    expires = formencode.validators.String(if_missing=None)

    #expires = formencode.validators.DateTime???
    read_only = formencode.validators.StringBool(if_missing=False)
    unauthenticated_access = formencode.validators.StringBool(if_missing=False)

class ModifyImageForm(formencode.Schema):
    allow_extra_fields = True
    filter_extra_fields = True

    name = formencode.validators.String(if_missing=None)
    description = formencode.validators.String(if_missing=None)

    os_variant = formencode.validators.String(if_missing=None)
    os_type = formencode.validators.String(if_missing=None)
    os_arch = formencode.validators.String(if_missing=None)
    hypervisor = formencode.validators.String(if_missing=None)
    owner = formencode.validators.String(if_missing=None)

    expires = formencode.validators.String(if_missing=None)
github apache / allura / HelloForge / helloforge / main.py View on Github external
                   history=V.StringBool(if_empty=False)))
    def search(self, q=None, history=None):
        'local wiki search'
        results = []
        count=0
        if not q:
            q = ''
        else:
            search_query = '''%s
            AND is_history_b:%s
            AND project_id_s:%s
            AND mount_point_s:%s''' % (
                q, history, c.project._id, c.app.config.options.mount_point)
            results = search.search(search_query) 
            if results: count=results.hits
        return dict(q=q, history=history, results=results or [], count=count)
github apache / allura / ForgeDiscussion / forgediscussion / controllers / root.py View on Github external
    @with_trailing_slash
    @expose('jinja:forgediscussion:templates/discussionforums/search.html')
    @validate(dict(q=validators.UnicodeString(if_empty=None),
                   history=validators.StringBool(if_empty=False),
                   project=validators.StringBool(if_empty=False),
                   limit=validators.Int(if_empty=None, if_invalid=None),
                   page=validators.Int(if_empty=0, if_invalid=0)))
    def search(self, q=None, history=None, project=None, limit=None, page=0, **kw):
        c.search_results = self.W.search_results
        c.help_modal = self.W.search_help
        search_params = kw
        search_params.update({
            'q': q or '',
            'history': history,
            'project': project,
            'limit': limit,
            'page': page,
            'allowed_types': ['Post', 'Post Snapshot', 'Discussion', 'Thread'],
        })
        d = search_app(**search_params)
        d['search_comments_disable'] = True
github apache / allura / ForgeTracker / forgetracker / tracker_main.py View on Github external
    @with_trailing_slash
    @h.vardec
    @expose('jinja:forgetracker:templates/tracker/milestone.html')
    @validate(validators=dict(
        limit=validators.Int(if_invalid=None),
        page=validators.Int(if_empty=0, if_invalid=0),
        sort=validators.UnicodeString(if_empty=''),
        filter=V.JsonConverter(if_empty={}),
        deleted=validators.StringBool(if_empty=False)))
    def index(self, q=None, columns=None, page=0, query=None, sort=None,
              deleted=False, filter=None, **kw):
        require(has_access(c.app, 'read'))
        show_deleted = [False]
        if deleted and has_access(c.app, 'delete'):
            show_deleted = [False, True]
        elif deleted and not has_access(c.app, 'delete'):
            deleted = False

        result = TM.Ticket.paged_query_or_search(c.app.config, c.user,
                                                 self.mongo_query,
                                                 self.solr_query,
                                                 filter, sort=sort, page=page,
                                                 deleted={'$in': show_deleted},
                                                 show_deleted=deleted, **kw)
github apache / allura / ForgeWiki / forgewiki / wiki_main.py View on Github external
                   show_deleted=validators.StringBool(if_empty=False),
                   page=validators.Int(if_empty=0, if_invalid=0),
                   limit=validators.Int(if_empty=None, if_invalid=None)))
    def browse_pages(self, sort='alpha', show_deleted=False, page=0, limit=None, **kw):
        'list of all pages in the wiki'
        c.page_list = W.page_list
        c.page_size = W.page_size
        limit, pagenum, start = g.handle_paging(limit, page, default=25)
        count = 0
        pages = []
        uv_pages = []
        criteria = dict(app_config_id=c.app.config._id)
        can_delete = has_access(c.app, 'delete')()
        show_deleted = show_deleted and can_delete
        if not can_delete:
            criteria['deleted'] = False
        q = WM.Page.query.find(criteria)
github apache / allura / ForgeShortUrl / forgeshorturl / main.py View on Github external
                   project=validators.StringBool(if_empty=False)))
    def search(self, q=None, project=None, limit=None, page=0, **kw):
        c.search_results = W.search_results
        c.help_modal = W.search_help
        search_params = kw
        search_params.update({
            'q': q or '',
            'project': project,
            'limit': limit,
            'page': page,
            'allowed_types': ['ShortUrl'],
        })
        if not has_access(c.app, 'view_private'):
            search_params['fq'] = ['private_b:False']
        d = search_app(**search_params)
        d['search_comments_disable'] = True
        d['search_history_disable'] = True
github apache / allura / ForgeWiki / forgewiki / wiki_main.py View on Github external
                   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'],
        })
        return search_app(**search_params)
github TurboGears / Ming / ming / config.py View on Github external
def configure_from_nested_dict(config):
    try:
        from formencode import schema, validators
    except ImportError:
        raise MingConfigError("Need to install FormEncode to use ``ming.configure``")

    class DatastoreSchema(schema.Schema):
        allow_extra_fields = True

        uri = validators.UnicodeString(if_missing=None, if_empty=None)
        database = validators.UnicodeString(if_missing=None, if_empty=None)
        connect_retry = validators.Number(if_missing=3, if_empty=0)
        auto_ensure_indexes = validators.StringBool(if_missing=True)
        # pymongo
        tz_aware = validators.Bool(if_missing=False)

    datastores = {}
    for name, datastore in six.iteritems(config):
        args = DatastoreSchema.to_python(datastore, None)
        database = args.pop("database", None)
        if database is None:
            datastores[name] = create_datastore(**args)
        else:
            datastores[name] = create_datastore(database=database, **args)
    Session._datastores = datastores
    # bind any existing sessions
    for name, session in six.iteritems(Session._registry):
        session.bind = datastores.get(name, None)
        session._name = name