How to use the colander.Schema function in colander

To help you get started, we’ve selected a few colander 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 VoteIT / voteit.core / voteit / core / plugins / password_auth / tests.py View on Github external
def test_modify_register_schema(self):
        schema = colander.Schema()
        obj = self._cut(None, None) #Proper context and request not needed here
        obj.modify_register_schema(schema)
        self.assertEqual('password', schema['password'].name)
github mazvv / travelcrm / travelcrm / forms / auth.py View on Github external
)
    return colander.All(colander.Email(), validator)


class LoginSchema(colander.Schema):
    username = colander.SchemaNode(
        colander.String(),
        missing=u''
    )
    password = colander.SchemaNode(
        colander.String(),
        missing=u'',
    )


class _ForgotSchema(colander.Schema):
    email = colander.SchemaNode(
        colander.String(),
        validator=email_validator,
    )


class ForgotForm(BaseForm):
    _schema = _ForgotSchema

    def submit(self):
        user = User.by_email(self._controls.get('email'))
        if user:
            schedule_user_password_recovery(
                self.request,
                user.id,
            )
github liqd / adhocracy3 / src / adhocracy / adhocracy / properties / interfaces.py View on Github external
"""Colander schema for IVersions."""

    elements = ReferenceSetSchemaNode(default=[],
                                      missing=colander.drop,
                                      interface=[IVersionable],
                                      )


class ITags(IProperty):

    """List all tags for this FubelVersionsPool."""

    taggedValue('schema', 'adhocracy.properties.interfaces.TagsSchema')


class TagsSchema(colander.Schema):

    """Colander schema for ITags."""

    elements = ReferenceSetSchemaNode(default=[],
                                      missing=colander.drop,
                                      interface=IVersionable,
                                      )


# Document Data

class IDocument(IProperty):

    """Marker interface representing a Fubel with document data."""

    taggedValue('schema', 'adhocracy.properties.interfaces.DocumentSchema')
github liqd / adhocracy3 / src / adhocracy / adhocracy / properties / interfaces.py View on Github external
from adhocracy.schema import (
    ReferenceSetSchemaNode,
    Identifier,
)

import colander


class IName(IProperty):

    """Human readable resource Identifier, used to build object paths."""

    taggedValue('schema', 'adhocracy.properties.interfaces.NameSchema')


class NameSchema(colander.Schema):

    """Colander schema for IName."""

    name = Identifier(default='', missing=colander.drop)


class INameReadOnly(IName):

    """ Same as IName but name is autogenerated."""

    taggedValue('schema', 'adhocracy.properties.interfaces.NameReadOnlySchema')


class NameReadOnlySchema(colander.Schema):

    """Colander schema for INameReadOnly."""
github VoteIT / voteit.core / voteit / core / plugins / hashlist_ap.py View on Github external
def config_schema(self):
        return HashlistAPConfigSchema()


@colander.deferred
def ap_hashlist_uid_widget(node, kw):
    request = kw['request']
    query = Eq('type_name', 'HashList')
    docids = request.root.catalog.query(query)[1]
    values = [('', _("<select>"))]
    for obj in request.resolve_docids(docids):
        values.append((obj.uid, obj.title))
    return deform.widget.SelectWidget(values=values)


class HashlistAPConfigSchema(colander.Schema):
    title = _("Configure access policy")
    description = _("Access will be granted if users are present in the hashlist.")
    ap_hashlist_uid = colander.SchemaNode(
        colander.String(),
        title=_("Hashlist"),
        description=_("ap_hashlist_uid_description",
                      default="If nothing is present here, it might mean that you "
                              "don't have permission to see any hashlists, "
                              "or that arche_hashlist isn't installed."),
        widget=ap_hashlist_uid_widget,
    )
    immediate_access_grant_roles = colander.SchemaNode(
        colander.Set(),
        title=_("Roles"),
        description=_("immediate_ap_schema_grant_description",
                      default="Users will be granted these roles upon requesting access and passing check."),</select>
github Pylons / deform / deform / schema.py View on Github external
result = widget.filedict(value)
        # provide a value for these entries even if None
        result["mimetype"] = value.get("mimetype")
        result["size"] = value.get("size")
        result["fp"] = value.get("fp")
        result["preview_url"] = value.get("preview_url")
        return result

    def deserialize(self, node, value):
        return value

    def cstruct_children(self, node, cstruct):  # pragma: no cover
        return []


class CSRFSchema(colander.Schema):
    """CSRF protected form schema.

    Example:

    .. code-block:: python

      import colander
      from deform.schema import CSRFSchema

      class MySchema(CSRFSchema):
          my_field = colander.SchemaNode(colander.String())

      And in your application code, *bind* the schema, passing the request as a
      keyword argument:

  .. code-block:: python
github eea / eea.corpus / src / eea.corpus / eea / corpus / schema.py View on Github external
return deform.widget.SelectWidget(
        values=choices,
        multiple=True
    )


class UploadSchema(Schema):
    # title = SchemaNode(String())
    upload = SchemaNode(
        deform.FileData(),
        widget=deform.widget.FileUploadWidget(tmpstore)
    )


class TopicExtractionSchema(Schema):
    topics = SchemaNode(
        Int(),
        default=10,
        title="Number of topics to extract"
    )
    num_docs = SchemaNode(
        Int(),
        default=100,
        title="Max number of documents to process"
    )
    ngrams = SchemaNode(
        Int(),
        default=1,
        title="ngram level generation for tokens"
    )
    weighting = SchemaNode(
github VoteIT / voteit.core / voteit / core / schemas / invite_ticket.py View on Github external
import colander
import deform

from voteit.core.validators import no_html_validator
from voteit.core.validators import multiple_email_validator
from voteit.core.schemas.common import strip_and_lowercase
from voteit.core import security
from voteit.core import _
from voteit.core.validators import deferred_token_form_validator


class ClaimTicketSchema(colander.Schema):
    validator = deferred_token_form_validator
    email = colander.SchemaNode(colander.String(),
                                title = _(u"Email address your invitation was sent to."),
                                validator = colander.Email(msg = _(u"Invalid email address.")),)
    #Note that validation for token depends on email, so it can't be set at field level.
    token = colander.SchemaNode(colander.String(),
                                title = _(u"claim_ticket_token_title",
                                          default = u"The access token your received in your email."),)


class AddTicketsSchema(colander.Schema):
    roles = colander.SchemaNode(
        colander.Set(),
        title = _(u"Roles"),
        default = (security.ROLE_VIEWER, security.ROLE_DISCUSS, security.ROLE_PROPOSE, security.ROLE_VOTER),
        description = _(u"add_tickets_roles_description",
github VoteIT / voteit.core / voteit / core / schemas / agenda_template.py View on Github external
from betahaus.pyracont.decorators import schema_factory
import colander
import deform

from voteit.core import VoteITMF as _
from voteit.core.validators import html_string_validator
from voteit.core.schemas.agenda_item import AgendaItemSchema


class AgendaItemSequenceSchema(colander.SequenceSchema):
    agenda_item = AgendaItemSchema(title=_(u'Agenda item'))


# @schema_factory('AgendaTemplateSchema',
#                 title = _(u"Agenda template"))
class AgendaTemplateSchema(colander.Schema):
    title = colander.SchemaNode(
        colander.String(),
        title=_("Template name"),
        validator=html_string_validator,)
    description = colander.SchemaNode(
        colander.String(),
        title = _("Description"),
        description = _("agenda_template_description_description",
                        default="Describe the purpose of this agenda"),
        widget=deform.widget.TextAreaWidget(rows=5, cols=40),
    )
    agenda_items = AgendaItemSequenceSchema(title=_('Agenda items'))


def includeme(config):
    config.add_content_schema('AgendaTemplate', AgendaTemplateSchema, 'edit')