How to use the colander.Integer 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 chrisrossi / limone / limone / tests.py View on Github external
def setUp(self):
        import colander
        import limone

        class NSAData(colander.Schema):
            serialnum = colander.SchemaNode(colander.Str('UTF-8'))
            date_of_contact = colander.SchemaNode(colander.Date())

        class PersonalData(colander.Schema):
            nsa_data = NSAData()
            n_arrests = colander.SchemaNode(colander.Int())

        class PersonSchema(colander.Schema):
            name = colander.SchemaNode(colander.Str('UTF-8'))
            age = colander.SchemaNode(colander.Integer(), default=500)
            personal = PersonalData()

        self.content_type = limone.make_content_type(PersonSchema, 'Person')
github mazvv / travelcrm / travelcrm / forms / subaccounts.py View on Github external
validator=source_id_validator
    )
    name = colander.SchemaNode(
        colander.String(),
        validator=name_validator
    )
    descr = colander.SchemaNode(
        colander.String(),
        missing=None,
        validator=colander.Length(max=255)
    )


class _SubaccountSearchSchema(ResourceSearchSchema):
    account_id = colander.SchemaNode(
        colander.Integer(),
        missing=None
    )


class SubaccountForm(BaseForm):
    _schema = _SubaccountSchema

    def submit(self, subaccount=None):
        if not subaccount:
            subaccount = Subaccount(
                resource=SubaccountsResource.create_resource(
                    get_auth_employee(self.request)
                )
            )
        else:
            subaccount.resource.notes = []
github paasmaker / paasmaker / paasmaker / pacemaker / controller / version.py View on Github external
# TODO: Remove files off disk or other systems.

		version.delete()
		self.session.add(version)
		self.session.commit()

		self.action_success(None, "/application/%d" % version.application.id)

	@staticmethod
	def get_routes(configuration):
		routes = []
		routes.append((r"/version/(\d+)/delete", VersionDeleteController, configuration))
		return routes

class VersionInstanceTypeUpdateQuantitySchema(colander.MappingSchema):
	quantity = colander.SchemaNode(colander.Integer(),
		title="Quantity",
		description="The quantity of instances of the type that you want.",
		validator=colander.Range(min=1))

class VersionInstanceTypeChangeCountController(VersionRootController):

	def post(self, instance_type_id):
		instance_type = self._get_instance_type(instance_type_id)

		# Check permissions.
		# You need APPLICATION_CREATE, because you can adjust the instance
		# count also by updating the manifest file.
		self.require_permission(
			constants.PERMISSION.APPLICATION_CREATE,
			workspace=instance_type.application_version.application.workspace
		)
github mazvv / travelcrm / travelcrm / forms / service_sale.py View on Github external
def deserialize(self, cstruct):
        if (
            'service_item_id' in cstruct
            and not isinstance(cstruct.get('service_item_id'), list)
        ):
            val = cstruct['service_item_id']
            cstruct['service_item_id'] = list()
            cstruct['service_item_id'].append(val)

        return super(ServiceSaleSchema, self).deserialize(cstruct)


class ServiceSaleSearchSchema(ResourceSearchSchema):
    person_id = colander.SchemaNode(
        colander.Integer(),
        missing=None,
    )
    service_id = colander.SchemaNode(
        colander.Integer(),
        missing=None,
    )
    price_from = colander.SchemaNode(
        colander.Money(),
        missing=None,
    )
    price_to = colander.SchemaNode(
        colander.Money(),
        missing=None,
    )
    sale_from = colander.SchemaNode(
        Date(),
github liqd / adhocracy3 / src / adhocracy_core / adhocracy_core / sheets / pool.py View on Github external
def after_bind(self, node: colander.MappingSchema, kw: dict):
        request = kw.get('request', None)
        if request is None:
            return
        if request.validated.get('count', False):
            child = colander.SchemaNode(colander.Integer(),
                                        default=0,
                                        missing=colander.drop,
                                        name='count')
            node.add(child)
        if request.validated.get('aggregateby', ''):
            child = colander.SchemaNode(colander.Mapping(unknown='preserve'),
                                        default={},
                                        missing=colander.drop,
                                        name='aggregateby')
            node.add(child)
github paasmaker / paasmaker / paasmaker / pacemaker / controller / role.py View on Github external
name = colander.SchemaNode(colander.String(),
		title="Role name",
		description="A nice name for this role.",
		validator=colander.Length(min=2))

	permissions = colander.SchemaNode(colander.Sequence(),
		colander.SchemaNode(colander.String()),
		title="Permissions",
		default=[],
		missing=[])

class RoleAllocationAssignSchema(colander.MappingSchema):
	role_id = colander.SchemaNode(colander.Integer(),
		title="Role ID",
		description="The role ID.")
	user_id = colander.SchemaNode(colander.Integer(),
		title="User ID",
		description="The user ID.")
	workspace_id = colander.SchemaNode(colander.Integer(),
		title="Optional Workspace ID",
		description="The workspace ID.",
		default=None,
		missing=None)

class RoleAllocationUnAssignSchema(colander.MappingSchema):
	allocation_id = colander.SchemaNode(colander.Integer(),
		title="Allocation ID",
		description="The allocation ID.")

class RoleListController(BaseController):
	AUTH_METHODS = [BaseController.SUPER, BaseController.USER]
github paasmaker / paasmaker / paasmaker / common / job / prepare / service.py View on Github external
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

import json

import paasmaker
from paasmaker.common.core import constants
from paasmaker.common.application.environment import ApplicationEnvironment
from ..base import BaseJob
from paasmaker.util.plugin import MODE

import colander

class ServiceJobParametersSchema(colander.MappingSchema):
	service_id = colander.SchemaNode(colander.Integer())

class ServiceContainerJob(BaseJob):
	"""
	A container job to build the environment for a set of created services.
	"""
	def start_job(self, context):
		# Fetch all the relevant services and put them into the environment
		# for the prepare tasks.
		def got_session(session):
			version = session.query(
				paasmaker.model.ApplicationVersion
			).get(
				context['application_version_id']
			)

			# Build our environment for later.
github paasmaker / paasmaker / paasmaker / common / job / coordinate / registerrequest.py View on Github external
import uuid

import paasmaker
from paasmaker.common.core import constants
from ..base import BaseJob
from paasmaker.util.plugin import MODE

import tornado
from pubsub import pub
import sqlalchemy

import colander

class RegisterRequestJobParametersSchema(colander.MappingSchema):
	application_instance_type_id = colander.SchemaNode(colander.Integer())

class RegisterRequestJob(BaseJob):
	MODES = {
		MODE.JOB: RegisterRequestJobParametersSchema()
	}

	def start_job(self, context):
		self.logger.info("Creating node registration jobs.")

		self.session = self.configuration.get_database_session()
		self.instance_type = self.session.query(
			paasmaker.model.ApplicationInstanceType
		).get(self.parameters['application_instance_type_id'])

		# Find all instances that need to be registered.
		# Attempt to grab all the data at once that is required.
github paasmaker / paasmaker / paasmaker / pacemaker / controller / node.py View on Github external
import tornado
import tornado.testing
import colander
import dateutil.parser

logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

class NodeRegisterSchema(colander.MappingSchema):
	name = colander.SchemaNode(colander.String(),
		title="Node Name",
		description="A nice name for the node.")
	route = colander.SchemaNode(colander.String(),
		title="Route to this node",
		description="The route to access this node for future. Can be a DNS name of IP address.")
	apiport = colander.SchemaNode(colander.Integer(),
		title="HTTP API port",
		description="The HTTP port to use to interact with this node.")
	tags = colander.SchemaNode(colander.Mapping(unknown='preserve'),
		title="User tags",
		description="A generic set of tags or information stored for the node. Can be used to write custom placement filters, or find nodes.")
	start_time = colander.SchemaNode(colander.String(),
		title="Node start time",
		description="An ISO 8601 formatted string representing the time the node started. In UTC.")
	instances = colander.SchemaNode(colander.Mapping(unknown='preserve'),
		title="Instance status",
		description="A map of instance statuses on the node.",
		default={},
		missing={})
	stats = colander.SchemaNode(colander.Mapping(unknown='preserve'),
		title="Node stats",
		description="The stats of the node, as reported by the node.")
github paasmaker / paasmaker / paasmaker / common / job / coordinate / shutdown.py View on Github external
callback(root_id)

		configuration.job_manager.add_tree(tree, on_tree_added, parent=parent)

	def start_job(self, context):
		def version_updated():
			self.logger.info("Shutdown instances and alter routing.")
			self.success({}, "Shut down instances and altered routing.")

		def jobs_updated():
			self.update_version_from_context(context, constants.VERSION.READY, version_updated)

		self.update_jobs_from_context(context, jobs_updated)

class ShutdownRequestJobParametersSchema(colander.MappingSchema):
	application_instance_type_id = colander.SchemaNode(colander.Integer())

class ShutdownRequestJob(InstanceJobHelper):
	"""
	A job to submit shutdown requests on specific heart nodes to shutdown instances.
	"""
	MODES = {
		MODE.JOB: ShutdownRequestJobParametersSchema()
	}

	def start_job(self, context):
		# We've been supplied with an instance type, so now locate all instances for
		# that type, and queue jobs for them.
		def got_session(session):
			instance_type = self.get_instance_type(session)
			instances = self.get_instances(
				session,