def build_rule_schema(ruleset, check_matrix): """ Accepts ruleset and a map of fields/possible operations and builds validation class """ schema = colander.SchemaNode(colander.Mapping()) schema.add(colander.SchemaNode(colander.String(), name='field')) if ruleset['field'] in ['__AND__', '__OR__', '__NOT__']: subrules = colander.SchemaNode(colander.Tuple(), name='rules') for rule in ruleset['rules']: subrules.add(build_rule_schema(rule, check_matrix)) schema.add(subrules) else: op_choices = check_matrix[ruleset['field']]['ops'] cast_to = check_matrix[ruleset['field']]['type'] schema.add( colander.SchemaNode(colander.String(), validator=colander.OneOf(op_choices), name='op')) schema.add( colander.SchemaNode(colander.String(), name='value', validator=RuleFieldType(cast_to))) return schema
def _colander_schema(self, instance, value): subfield = colander.SchemaNode(colander.Tuple()) subfield.add(colander.SchemaNode(colander.String(), name='subkey')) subfield.add(colander.SchemaNode(colander.String(), name='value')) return colander.SchemaNode(colander.Sequence(), subfield, name=self.name)
def _colander_schema(self, instance, value): schema = colander.SchemaNode(colander.Tuple()) for subkey in self.subkeys: schema.add(colander.SchemaNode(colander.String(), name=subkey)) return colander.SchemaNode(colander.Sequence(), schema, name=self.name)
ref_type = RedisReferenceType() name_ref_type = PrefixedRedisReferenceType() value_type = RedisValueType() int_type = colander.Integer() float_type = colander.Float() bool_type = colander.Boolean() datetime_type = colander.DateTime() string_bool = StringBool() bin_type = BinaryValueType() def node(schema, *args, **kwargs): schema.add(colander.SchemaNode(*args, **kwargs)) NameValueTupleSchema = colander.SchemaNode(colander.Tuple()) NameValueTupleSchema.add(colander.SchemaNode(name_ref_type, name='name')) NameValueTupleSchema.add(colander.SchemaNode(value_type, name='value')) class NameValueListSchemaNode(LarkSchemaNode): def from_request(self, args=None, kwargs=None, query_dict=None, request_json=None, redis_prefix=None): cstruct = {'value': request_json} # print "Going to deserialize: %s" % (cstruct) self.redis_prefix = redis_prefix data = self.deserialize(cstruct)
class ConfigurationSchema(colander.MappingSchema): """Configuration schema for django-pipeline. Reference is https://github.com/cyberdelia/django-pipeline/blob/master/pipeline/conf.py """ PIPELINE_CLOSURE_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_CLOSURE_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env closure', ) PIPELINE_COFFEE_SCRIPT_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_COFFEE_SCRIPT_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env coffee', ) PIPELINE_COMPILERS = colander.SchemaNode( colander.Sequence(), missing=colander.drop, default=[], children=[colander.SchemaNode(colander.String())]) PIPELINE_CSS = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=colander.null, default={}, children=[ colander.SchemaNode( colander.Mapping(unknown='ignore'), missing=colander.drop, default={}, children=[ colander.SchemaNode( colander.Sequence(), name='source_filenames', missing=colander.required, default=[], children=[colander.SchemaNode(colander.String())]), colander.SchemaNode( colander.String(), name='output_filename', missing=colander.required, default='', ), colander.SchemaNode( colander.String(), name='variant', missing=colander.drop, default=colander.null, ), colander.SchemaNode( colander.String(), name='template_name', missing=colander.drop, default=colander.null, ), colander.SchemaNode( colander.Mapping(unknown='preserve'), name='extra_context', missing=colander.drop, default={}, ), colander.SchemaNode( colander.Boolean(), name='manifest', missing=colander.drop, default=True, ), ]), ]) PIPELINE_CSS_COMPRESSOR = colander.SchemaNode( colander.String(), missing=colander.drop, default='pipeline.compressors.yuglify.YuglifyCompressor', ) PIPELINE_CSSMIN_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_CSSMIN_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env cssmin', ) PIPELINE_CSSTIDY_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='--template=highest', ) PIPELINE_CSSTIDY_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env csstidy', ) PIPELINE_DISABLE_WRAPPER = colander.SchemaNode( colander.Boolean(), missing=colander.drop, default=False, ) PIPELINE_EMBED_MAX_IMAGE_SIZE = colander.SchemaNode( colander.Integer(), missing=colander.drop, default=32700, ) PIPELINE_EMBED_PATH = colander.SchemaNode( colander.String(), missing=colander.drop, default='[/]?embed/', ) PIPELINE_ENABLED = colander.SchemaNode( colander.Boolean(), missing=colander.drop, default=colander.null, ) PIPELINE_JS = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=colander.null, default={}, children=[ colander.SchemaNode( colander.Mapping(unknown='ignore'), missing=colander.drop, default={}, children=[ colander.SchemaNode( colander.Sequence(), name='source_filenames', missing=colander.required, default=[], children=[colander.SchemaNode(colander.String())]), colander.SchemaNode( colander.String(), name='output_filename', missing=colander.required, default='', ), colander.SchemaNode( colander.String(), name='variant', missing=colander.drop, default=colander.null, ), colander.SchemaNode( colander.String(), name='template_name', missing=colander.drop, default=colander.null, ), colander.SchemaNode( colander.Mapping(unknown='preserve'), name='extra_context', missing=colander.drop, default={}, ), colander.SchemaNode( colander.Boolean(), name='manifest', missing=colander.drop, default=True, ), ]), ]) PIPELINE_JS_COMPRESSOR = colander.SchemaNode( colander.String(), missing=colander.drop, default='pipeline.compressors.yuglify.YuglifyCompressor', ) PIPELINE_LESS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_LESS_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env lessc', ) PIPELINE_LIVE_SCRIPT_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_LIVE_SCRIPT_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env lsc', ) PIPELINE_MIMETYPES = colander.SchemaNode( colander.Sequence(), missing=colander.drop, default=( ('text/coffeescript', '.coffee'), ('text/less', '.less'), ('text/javascript', '.js'), ('text/x-sass', '.sass'), ('text/x-scss', '.scss'), ), children=[ colander.SchemaNode(colander.Tuple(), missing=colander.drop, default=colander.null, children=[ colander.SchemaNode(colander.String()), colander.SchemaNode(colander.String()), ]), ]) PIPELINE_ROOT = colander.SchemaNode( colander.String(), missing=colander.drop, default=colander.null, ) PIPELINE_SASS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='--update', ) PIPELINE_SASS_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env sass', ) PIPELINE_STORAGE = colander.SchemaNode( colander.String(), missing=colander.drop, default='pipeline.storage.PipelineFinderStorage', ) PIPELINE_STYLUS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_STYLUS_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env stylus', ) PIPELINE_TEMPLATE_EXT = colander.SchemaNode( colander.String(), missing=colander.drop, default='.jst', ) PIPELINE_TEMPLATE_FUNC = colander.SchemaNode( colander.String(), missing=colander.drop, default='template', ) PIPELINE_TEMPLATE_NAMESPACE = colander.SchemaNode( colander.String(), missing=colander.drop, default='window.JST', ) PIPELINE_TEMPLATE_SEPARATOR = colander.SchemaNode( colander.String(), missing=colander.drop, default='_', ) PIPELINE_UGLIFYJS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_UGLIFYJS_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env uglifyjs', ) PIPELINE_URL = colander.SchemaNode( colander.String(), missing=colander.drop, default=colander.null, ) PIPELINE_YUGLIFY_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env yuglify', ) PIPELINE_YUGLIFY_CSS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='--terminal', ) PIPELINE_YUGLIFY_JS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='--terminal', ) PIPELINE_YUI_BINARY = colander.SchemaNode( colander.String(), missing=colander.drop, default='/usr/bin/env yuicompressor', ) PIPELINE_YUI_CSS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', ) PIPELINE_YUI_JS_ARGUMENTS = colander.SchemaNode( colander.String(), missing=colander.drop, default='', )
class Django1_7ConfigurationSchema(colander.MappingSchema): """Configuration schema for Django 1.7.""" ABSOLUTE_URL_OVERRIDES = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=global_settings.ABSOLUTE_URL_OVERRIDES, default=global_settings.ABSOLUTE_URL_OVERRIDES, ) ADMIN_FOR = colander.SchemaNode( colander.Sequence(), missing=global_settings.ADMIN_FOR, default=global_settings.ADMIN_FOR, children=[ colander.SchemaNode(colander.String()), ] ) ADMINS = colander.SchemaNode( colander.Sequence(), missing=global_settings.ADMINS, default=global_settings.ADMINS, children=[ colander.SchemaNode( colander.Tuple(), children=[ colander.SchemaNode(colander.String()), colander.SchemaNode( colander.String(), validator=colander.Email(), ), ] ), ] ) ALLOWED_HOSTS = colander.SchemaNode( colander.Sequence(), missing=global_settings.ALLOWED_HOSTS, default=global_settings.ALLOWED_HOSTS, children=[ colander.SchemaNode(colander.String()), ] ) ALLOWED_INCLUDE_ROOTS = colander.SchemaNode( colander.Sequence(), missing=global_settings.ALLOWED_INCLUDE_ROOTS, default=global_settings.ALLOWED_INCLUDE_ROOTS, children=[ colander.SchemaNode(colander.String()), ] ) APPEND_SLASH = colander.SchemaNode( colander.Boolean(), missing=global_settings.APPEND_SLASH, default=global_settings.APPEND_SLASH, ) AUTHENTICATION_BACKENDS = colander.SchemaNode( colander.Sequence(), missing=global_settings.AUTHENTICATION_BACKENDS, default=global_settings.AUTHENTICATION_BACKENDS, children=[ colander.SchemaNode(colander.String()), ] ) AUTH_USER_MODEL = colander.SchemaNode( colander.String(), missing=global_settings.AUTH_USER_MODEL, default=global_settings.AUTH_USER_MODEL, ) CACHES = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=global_settings.CACHES, default=global_settings.CACHES, children=[ colander.SchemaNode( colander.Mapping(unknown='raise'), name='default', missing=colander.drop, children=[ colander.SchemaNode( colander.String(), name='BACKEND', missing=colander.required, default=colander.null, ), colander.SchemaNode( colander.String(), name='KEY_FUNCTION', missing=colander.drop, default='', ), colander.SchemaNode( colander.String(), name='KEY_PREFIX', missing=colander.drop, default='', ), colander.SchemaNode( colander.String(), name='LOCATION', missing=colander.drop, default='', ), colander.SchemaNode( colander.Mapping(unknown='preserve'), name='OPTIONS', missing=colander.drop, default={}, ), colander.SchemaNode( colander.Integer(), name='TIMEOUT', missing=colander.drop, default=300, ), colander.SchemaNode( colander.String(), name='VERSION', missing=colander.drop, default=1, ), ] ), ] ) CACHE_MIDDLEWARE_ALIAS = colander.SchemaNode( colander.String(), missing=global_settings.CACHE_MIDDLEWARE_ALIAS, default=global_settings.CACHE_MIDDLEWARE_ALIAS, ) CACHE_MIDDLEWARE_ANONYMOUS_ONLY = colander.SchemaNode( colander.Boolean(), missing=colander.drop, # Not in django.conf.global_settings. default=False, ) CACHE_MIDDLEWARE_KEY_PREFIX = colander.SchemaNode( colander.String(), missing=global_settings.CACHE_MIDDLEWARE_KEY_PREFIX, default=global_settings.CACHE_MIDDLEWARE_KEY_PREFIX, ) CACHE_MIDDLEWARE_SECONDS = colander.SchemaNode( colander.Integer(), missing=global_settings.CACHE_MIDDLEWARE_SECONDS, default=global_settings.CACHE_MIDDLEWARE_SECONDS, ) COMMENTS_ALLOW_PROFANITIES = colander.SchemaNode( colander.Boolean(), missing=False, default=False, ) CSRF_COOKIE_AGE = colander.SchemaNode( colander.Integer(), missing=global_settings.CSRF_COOKIE_AGE, default=global_settings.CSRF_COOKIE_AGE, ) CSRF_COOKIE_DOMAIN = colander.SchemaNode( colander.String(), missing=global_settings.CSRF_COOKIE_DOMAIN, default=global_settings.CSRF_COOKIE_DOMAIN, ) CSRF_COOKIE_HTTPONLY = colander.SchemaNode( colander.Boolean(), missing=global_settings.CSRF_COOKIE_HTTPONLY, default=global_settings.CSRF_COOKIE_HTTPONLY, ) CSRF_COOKIE_NAME = colander.SchemaNode( colander.String(), missing=global_settings.CSRF_COOKIE_NAME, default=global_settings.CSRF_COOKIE_NAME, ) CSRF_COOKIE_PATH = colander.SchemaNode( colander.String(), missing=global_settings.CSRF_COOKIE_PATH, default=global_settings.CSRF_COOKIE_PATH, ) CSRF_COOKIE_SECURE = colander.SchemaNode( colander.Boolean(), missing=global_settings.CSRF_COOKIE_SECURE, default=global_settings.CSRF_COOKIE_SECURE, ) CSRF_FAILURE_VIEW = colander.SchemaNode( colander.String(), missing=global_settings.CSRF_FAILURE_VIEW, default=global_settings.CSRF_FAILURE_VIEW, ) DATABASES = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=colander.required, default=colander.null, children=[ colander.SchemaNode( colander.Mapping(unknown='raise'), name='default', missing=None, children=[ # See django.db.utils.ConnectionHandler.ensure_defaults colander.SchemaNode( colander.String(), name='ENGINE', missing=colander.drop, default='', ), colander.SchemaNode( colander.String(), name='HOST', missing=colander.drop, default='', ), colander.SchemaNode( colander.String(), name='NAME', missing=colander.drop, default='', ), colander.SchemaNode( colander.Mapping(unknown='preserve'), name='OPTIONS', missing=colander.drop, default={}, ), colander.SchemaNode( colander.String(), name='PASSWORD', missing=colander.drop, default='', ), colander.SchemaNode( colander.String(), name='PORT', missing=colander.drop, default='', ), colander.SchemaNode( colander.String(), name='USER', missing=colander.drop, default='', ), colander.SchemaNode( colander.Boolean(), name='ATOMIC_REQUESTS', missing=colander.drop, default=False, ), colander.SchemaNode( colander.Boolean(), name='AUTOCOMMIT', missing=colander.drop, default=True, ), colander.SchemaNode( colander.Integer(), name='CONN_MAX_AGE', missing=colander.drop, default=0, ), colander.SchemaNode( colander.Mapping(unknown='raise'), name='default', missing=None, children=[ colander.SchemaNode( colander.String(), name='CHARSET', missing=colander.drop, default=None, ), colander.SchemaNode( colander.String(), name='COLLATION', missing=colander.drop, default=None, ), colander.SchemaNode( colander.Sequence(), name='DEPENDENCIES', missing=colander.drop, default=['default'], children=[ colander.SchemaNode(colander.String()), ] ), colander.SchemaNode( colander.String(), name='MIRROR', missing=colander.drop, default=None, ), colander.SchemaNode( colander.String(), name='NAME', missing=colander.drop, default=None, ), colander.SchemaNode( colander.Boolean(), name='CREATE_DB', missing=colander.drop, default=True, ), colander.SchemaNode( colander.String(), name='USER', missing=colander.drop, default=None, ), colander.SchemaNode( colander.Boolean(), name='CREATE_USER', missing=colander.drop, default=True, ), colander.SchemaNode( colander.String(), name='PASSWORD', missing=colander.drop, default=None, ), colander.SchemaNode( colander.String(), name='TBLSPACE', missing=colander.drop, default=None, ), colander.SchemaNode( colander.String(), name='TBLSPACE_TMP', missing=colander.drop, default=None, ), ] ), ] ), ] ) DATABASE_ROUTERS = colander.SchemaNode( colander.Sequence(), missing=global_settings.DATABASE_ROUTERS, default=global_settings.DATABASE_ROUTERS, children=[ colander.SchemaNode( colander.String(), ), ] ) DATE_FORMAT = colander.SchemaNode( colander.String(), missing=global_settings.DATE_FORMAT, default=global_settings.DATE_FORMAT, ) DATE_INPUT_FORMATS = colander.SchemaNode( colander.Sequence(), missing=global_settings.DATE_INPUT_FORMATS, default=global_settings.DATE_INPUT_FORMATS, children=[ colander.SchemaNode( colander.String(), ), ] ) DATETIME_FORMAT = colander.SchemaNode( colander.String(), missing=global_settings.DATETIME_FORMAT, default=global_settings.DATETIME_FORMAT, ) DATETIME_INPUT_FORMATS = colander.SchemaNode( colander.Sequence(), missing=global_settings.DATETIME_INPUT_FORMATS, default=global_settings.DATETIME_INPUT_FORMATS, children=[ colander.SchemaNode( colander.String(), ), ] ) DEBUG = colander.SchemaNode( colander.Boolean(), missing=global_settings.DEBUG, default=global_settings.DEBUG, ) DEBUG_PROPAGATE_EXCEPTIONS = colander.SchemaNode( colander.Boolean(), missing=global_settings.DEBUG, default=global_settings.DEBUG, ) DECIMAL_SEPARATOR = colander.SchemaNode( colander.String(), missing=global_settings.DECIMAL_SEPARATOR, default=global_settings.DECIMAL_SEPARATOR, ) DEFAULT_CHARSET = colander.SchemaNode( colander.String(), missing=global_settings.DEFAULT_CHARSET, default=global_settings.DEFAULT_CHARSET, ) DEFAULT_CONTENT_TYPE = colander.SchemaNode( colander.String(), missing=global_settings.DEFAULT_CONTENT_TYPE, default=global_settings.DEFAULT_CONTENT_TYPE, ) DEFAULT_EXCEPTION_REPORTER_FILTER = colander.SchemaNode( colander.String(), missing=global_settings.DEFAULT_EXCEPTION_REPORTER_FILTER, default=global_settings.DEFAULT_EXCEPTION_REPORTER_FILTER, ) DEFAULT_FILE_STORAGE = colander.SchemaNode( colander.String(), missing=global_settings.DEFAULT_FILE_STORAGE, default=global_settings.DEFAULT_FILE_STORAGE, ) DEFAULT_FROM_EMAIL = colander.SchemaNode( colander.String(), missing=global_settings.DEFAULT_FROM_EMAIL, default=global_settings.DEFAULT_FROM_EMAIL, validator=colander.Email(), ) DEFAULT_INDEX_TABLESPACE = colander.SchemaNode( colander.String(), missing=global_settings.DEFAULT_INDEX_TABLESPACE, default=global_settings.DEFAULT_INDEX_TABLESPACE, ) DEFAULT_TABLESPACE = colander.SchemaNode( colander.String(), missing=global_settings.DEFAULT_TABLESPACE, default=global_settings.DEFAULT_TABLESPACE, ) DISALLOWED_USER_AGENTS = colander.SchemaNode( colander.Sequence(), missing=global_settings.DISALLOWED_USER_AGENTS, default=global_settings.DISALLOWED_USER_AGENTS, children=[ colander.SchemaNode( colander.String(), ), ] ) EMAIL_BACKEND = colander.SchemaNode( colander.String(), missing=global_settings.EMAIL_BACKEND, default=global_settings.EMAIL_BACKEND, ) EMAIL_FILE_PATH = colander.SchemaNode( colander.String(), missing=colander.drop, # Not in djanco.conf.globalsettings default=colander.null, ) EMAIL_HOST = colander.SchemaNode( colander.String(), missing=global_settings.EMAIL_HOST, default=global_settings.EMAIL_HOST, ) EMAIL_HOST_PASSWORD = colander.SchemaNode( colander.String(), missing=global_settings.EMAIL_HOST_PASSWORD, default=global_settings.EMAIL_HOST_PASSWORD, ) EMAIL_HOST_USER = colander.SchemaNode( colander.String(), missing=global_settings.EMAIL_HOST_USER, default=global_settings.EMAIL_HOST_USER, ) EMAIL_PORT = colander.SchemaNode( colander.Integer(), missing=global_settings.EMAIL_PORT, default=global_settings.EMAIL_PORT, ) EMAIL_SUBJECT_PREFIX = colander.SchemaNode( colander.String(), missing=global_settings.EMAIL_SUBJECT_PREFIX, default=global_settings.EMAIL_SUBJECT_PREFIX, ) EMAIL_USE_TLS = colander.SchemaNode( colander.Boolean(), missing=global_settings.EMAIL_USE_TLS, default=global_settings.EMAIL_USE_TLS, ) EMAIL_USE_SSL = colander.SchemaNode( colander.Boolean(), missing=global_settings.EMAIL_USE_SSL, default=global_settings.EMAIL_USE_SSL, ) FORMAT_MODULE_PATH = colander.SchemaNode( colander.String(), missing=global_settings.FORMAT_MODULE_PATH, default=global_settings.FORMAT_MODULE_PATH, ) FILE_CHARSET = colander.SchemaNode( colander.String(), missing=global_settings.FILE_CHARSET, default=global_settings.FILE_CHARSET, ) FILE_UPLOAD_DIRECTORY_PERMISSIONS = colander.SchemaNode( colander.String(), missing=global_settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS, default=global_settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS, ) FILE_UPLOAD_HANDLERS = colander.SchemaNode( colander.Sequence(), missing=global_settings.FILE_UPLOAD_HANDLERS, default=global_settings.FILE_UPLOAD_HANDLERS, children=[ colander.SchemaNode( colander.String(), ), ] ) FILE_UPLOAD_MAX_MEMORY_SIZE = colander.SchemaNode( colander.Integer(), missing=global_settings.FILE_UPLOAD_MAX_MEMORY_SIZE, default=global_settings.FILE_UPLOAD_MAX_MEMORY_SIZE, ) FILE_UPLOAD_PERMISSIONS = colander.SchemaNode( colander.Integer(), missing=global_settings.FILE_UPLOAD_PERMISSIONS, default=global_settings.FILE_UPLOAD_PERMISSIONS, ) FILE_UPLOAD_TEMP_DIR = colander.SchemaNode( colander.String(), missing=global_settings.FILE_UPLOAD_TEMP_DIR, default=global_settings.FILE_UPLOAD_TEMP_DIR, ) FIRST_DAY_OF_WEEK = colander.SchemaNode( colander.Integer(), missing=global_settings.FIRST_DAY_OF_WEEK, default=global_settings.FIRST_DAY_OF_WEEK, ) FIXTURE_DIRS = colander.SchemaNode( colander.Sequence(), missing=global_settings.FIXTURE_DIRS, default=global_settings.FIXTURE_DIRS, children=[ colander.SchemaNode( colander.String(), ), ] ) FORCE_SCRIPT_NAME = colander.SchemaNode( colander.String(), missing=global_settings.FORCE_SCRIPT_NAME, default=global_settings.FORCE_SCRIPT_NAME, ) IGNORABLE_404_URLS = colander.SchemaNode( colander.Sequence(), missing=global_settings.IGNORABLE_404_URLS, default=global_settings.IGNORABLE_404_URLS, children=[ colander.SchemaNode( colander.String(), ), ] ) INSTALLED_APPS = colander.SchemaNode( colander.Sequence(), missing=colander.required, default=colander.null, children=[ colander.SchemaNode(colander.String()), ] ) INTERNAL_IPS = colander.SchemaNode( colander.Sequence(), missing=global_settings.INTERNAL_IPS, default=global_settings.INTERNAL_IPS, children=[ colander.SchemaNode(colander.String()), ] ) LANGUAGE_CODE = colander.SchemaNode( colander.String(), missing=global_settings.LANGUAGE_CODE, default=global_settings.LANGUAGE_CODE, ) LANGUAGE_COOKIE_AGE = colander.SchemaNode( colander.Integer(), missing=global_settings.LANGUAGE_COOKIE_AGE, default=global_settings.LANGUAGE_COOKIE_AGE, ) LANGUAGE_COOKIE_DOMAIN = colander.SchemaNode( colander.String(), missing=global_settings.LANGUAGE_COOKIE_DOMAIN, default=global_settings.LANGUAGE_COOKIE_DOMAIN, ) LANGUAGE_COOKIE_NAME = colander.SchemaNode( colander.String(), missing=global_settings.LANGUAGE_COOKIE_NAME, default=global_settings.LANGUAGE_COOKIE_NAME, ) LANGUAGE_COOKIE_PATH = colander.SchemaNode( colander.String(), missing=global_settings.LANGUAGE_COOKIE_PATH, default=global_settings.LANGUAGE_COOKIE_PATH, ) LANGUAGES = colander.SchemaNode( colander.Sequence(), missing=global_settings.LANGUAGES, default=global_settings.LANGUAGES, children=[ colander.SchemaNode( colander.Tuple(), children=[ colander.SchemaNode(colander.String()), colander.SchemaNode(colander.String()), ] ), ] ) LANGUAGES_BIDI = colander.SchemaNode( colander.Sequence(), missing=global_settings.LANGUAGES_BIDI, default=global_settings.LANGUAGES_BIDI, children=[ colander.SchemaNode(colander.String()), ] ) LOCALE_PATHS = colander.SchemaNode( colander.Sequence(), missing=global_settings.LOCALE_PATHS, default=global_settings.LOCALE_PATHS, children=[ colander.SchemaNode(colander.String()), ] ) LOGGING = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=global_settings.LOGGING, default=global_settings.LOGGING, ) LOGGING_CONFIG = colander.SchemaNode( colander.String(), missing=global_settings.LOGGING_CONFIG, default=global_settings.LOGGING_CONFIG, ) LOGIN_REDIRECT_URL = colander.SchemaNode( colander.String(), missing=global_settings.LOGIN_REDIRECT_URL, default=global_settings.LOGIN_REDIRECT_URL, ) LOGIN_URL = colander.SchemaNode( colander.String(), missing=global_settings.LOGIN_URL, default=global_settings.LOGIN_URL, ) LOGOUT_URL = colander.SchemaNode( colander.String(), missing=global_settings.LOGOUT_URL, default=global_settings.LOGOUT_URL, ) MANAGERS = colander.SchemaNode( colander.Sequence(), missing=global_settings.MANAGERS, default=global_settings.MANAGERS, children=[ colander.SchemaNode( colander.Tuple(), children=[ colander.SchemaNode(colander.String()), colander.SchemaNode( colander.String(), validator=colander.Email(), ), ] ), ] ) MEDIA_ROOT = colander.SchemaNode( colander.String(), missing=global_settings.MEDIA_ROOT, default=global_settings.MEDIA_ROOT, ) MEDIA_URL = colander.SchemaNode( colander.String(), missing=global_settings.MEDIA_URL, default=global_settings.MEDIA_URL, ) MESSAGE_LEVEL = colander.SchemaNode( colander.Integer(), missing=colander.drop, # Not in django.conf.global_settings default=messages.INFO, ) MESSAGE_STORAGE = colander.SchemaNode( colander.String(), missing=global_settings.MESSAGE_STORAGE, default=global_settings.MESSAGE_STORAGE, ) MESSAGE_TAGS = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=colander.drop, # Not in django.conf.global_settings default=messages.DEFAULT_TAGS, children=[ colander.SchemaNode( colander.String(), ), ] ) MIDDLEWARE_CLASSES = colander.SchemaNode( colander.Sequence(), missing=global_settings.MIDDLEWARE_CLASSES, default=global_settings.MIDDLEWARE_CLASSES, children=[ colander.SchemaNode(colander.String()), ] ) MIGRATION_MODULES = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=global_settings.MIGRATION_MODULES, default=global_settings.MIGRATION_MODULES, ) MONTH_DAY_FORMAT = colander.SchemaNode( colander.String(), missing=global_settings.MONTH_DAY_FORMAT, default=global_settings.MONTH_DAY_FORMAT, ) NUMBER_GROUPING = colander.SchemaNode( colander.Integer(), missing=global_settings.NUMBER_GROUPING, default=global_settings.NUMBER_GROUPING, ) PASSWORD_HASHERS = colander.SchemaNode( colander.Sequence(), missing=global_settings.PASSWORD_HASHERS, default=global_settings.PASSWORD_HASHERS, children=[ colander.SchemaNode( colander.String(), ), ] ) PASSWORD_RESET_TIMEOUT_DAYS = colander.SchemaNode( colander.Integer(), missing=global_settings.PASSWORD_RESET_TIMEOUT_DAYS, default=global_settings.PASSWORD_RESET_TIMEOUT_DAYS, ) PREPEND_WWW = colander.SchemaNode( colander.Boolean(), missing=global_settings.PREPEND_WWW, default=global_settings.PREPEND_WWW, ) PROFANITIES_LIST = colander.SchemaNode( colander.Sequence(), missing=global_settings.PROFANITIES_LIST, default=global_settings.PROFANITIES_LIST, children=[ colander.SchemaNode( colander.String(), ), ] ) RESTRUCTUREDTEXT_FILTER_SETTINGS = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=colander.drop, # Not in django.conf.global_settings default={}, ) ROOT_URLCONF = colander.SchemaNode( colander.String(), missing=colander.drop, # Not in django.conf.global_settings default=colander.null, ) SECRET_KEY = colander.SchemaNode( colander.String(), missing=colander.required, default=colander.null, ) SECURE_PROXY_SSL_HEADER = colander.SchemaNode( TupleOrNone(), missing=global_settings.SECURE_PROXY_SSL_HEADER, default=global_settings.SECURE_PROXY_SSL_HEADER, children=[ colander.SchemaNode(colander.String()), colander.SchemaNode(colander.String()), ] ) SEND_BROKEN_LINK_EMAILS = colander.SchemaNode( colander.Boolean(), missing=global_settings.SEND_BROKEN_LINK_EMAILS, default=global_settings.SEND_BROKEN_LINK_EMAILS, ) SERIALIZATION_MODULES = colander.SchemaNode( colander.Mapping(unknown='preserve'), missing=colander.drop, default={}, children=[ colander.SchemaNode( colander.String(), ), ] ) SERVER_EMAIL = colander.SchemaNode( colander.String(), missing=global_settings.SERVER_EMAIL, default=global_settings.SERVER_EMAIL, ) SESSION_COOKIE_AGE = colander.SchemaNode( colander.Integer(), missing=global_settings.SESSION_COOKIE_AGE, default=global_settings.SESSION_COOKIE_AGE, ) SESSION_COOKIE_DOMAIN = colander.SchemaNode( colander.String(), missing=global_settings.SESSION_COOKIE_DOMAIN, default=global_settings.SESSION_COOKIE_DOMAIN, ) SESSION_COOKIE_HTTPONLY = colander.SchemaNode( colander.Boolean(), missing=global_settings.SESSION_COOKIE_HTTPONLY, default=global_settings.SESSION_COOKIE_HTTPONLY, ) SESSION_COOKIE_NAME = colander.SchemaNode( colander.String(), missing=global_settings.SESSION_COOKIE_NAME, default=global_settings.SESSION_COOKIE_NAME, ) SESSION_COOKIE_PATH = colander.SchemaNode( colander.String(), missing=global_settings.SESSION_COOKIE_PATH, default=global_settings.SESSION_COOKIE_PATH, ) SESSION_CACHE_ALIAS = colander.SchemaNode( colander.String(), missing=global_settings.SESSION_CACHE_ALIAS, default=global_settings.SESSION_CACHE_ALIAS, ) SESSION_COOKIE_SECURE = colander.SchemaNode( colander.Boolean(), missing=global_settings.SESSION_COOKIE_SECURE, default=global_settings.SESSION_COOKIE_SECURE, ) SESSION_ENGINE = colander.SchemaNode( colander.String(), missing=global_settings.SESSION_ENGINE, default=global_settings.SESSION_ENGINE, ) SESSION_EXPIRE_AT_BROWSER_CLOSE = colander.SchemaNode( colander.Boolean(), missing=global_settings.SESSION_EXPIRE_AT_BROWSER_CLOSE, default=global_settings.SESSION_EXPIRE_AT_BROWSER_CLOSE, ) SESSION_FILE_PATH = colander.SchemaNode( colander.String(), missing=global_settings.SESSION_FILE_PATH, default=global_settings.SESSION_FILE_PATH, ) SESSION_SAVE_EVERY_REQUEST = colander.SchemaNode( colander.Boolean(), missing=global_settings.SESSION_SAVE_EVERY_REQUEST, default=global_settings.SESSION_SAVE_EVERY_REQUEST, ) SESSION_SERIALIZER = colander.SchemaNode( colander.String(), missing=global_settings.SESSION_SERIALIZER, default=global_settings.SESSION_SERIALIZER, ) SHORT_DATE_FORMAT = colander.SchemaNode( colander.String(), missing=global_settings.SHORT_DATE_FORMAT, default=global_settings.SHORT_DATE_FORMAT, ) SHORT_DATETIME_FORMAT = colander.SchemaNode( colander.String(), missing=global_settings.SHORT_DATETIME_FORMAT, default=global_settings.SHORT_DATETIME_FORMAT, ) SIGNING_BACKEND = colander.SchemaNode( colander.String(), missing=global_settings.SIGNING_BACKEND, default=global_settings.SIGNING_BACKEND, ) SILENCED_SYSTEM_CHECKS = colander.SchemaNode( colander.Sequence(), missing=global_settings.SILENCED_SYSTEM_CHECKS, default=global_settings.SILENCED_SYSTEM_CHECKS, children=[ colander.SchemaNode(colander.String()), ] ) SITE_ID = colander.SchemaNode( colander.Integer(), missing=colander.drop, default=colander.null, ) STATIC_ROOT = colander.SchemaNode( colander.String(), missing=global_settings.STATIC_ROOT, default=global_settings.STATIC_ROOT, ) STATIC_URL = colander.SchemaNode( colander.String(), missing=global_settings.STATIC_URL, default=global_settings.STATIC_URL, ) STATICFILES_DIRS = colander.SchemaNode( colander.Sequence(), missing=global_settings.STATICFILES_DIRS, default=global_settings.STATICFILES_DIRS, children=[ colander.SchemaNode(colander.String()), ] ) STATICFILES_FINDERS = colander.SchemaNode( colander.Sequence(), missing=global_settings.STATICFILES_FINDERS, default=global_settings.STATICFILES_FINDERS, children=[ colander.SchemaNode(colander.String()), ] ) STATICFILES_STORAGE = colander.SchemaNode( colander.String(), missing=global_settings.STATICFILES_STORAGE, default=global_settings.STATICFILES_STORAGE, ) TEMPLATE_CONTEXT_PROCESSORS = colander.SchemaNode( colander.Sequence(), missing=global_settings.TEMPLATE_CONTEXT_PROCESSORS, default=global_settings.TEMPLATE_CONTEXT_PROCESSORS, children=[ colander.SchemaNode(colander.String()), ] ) TEMPLATE_DEBUG = colander.SchemaNode( colander.Boolean(), missing=global_settings.TEMPLATE_DEBUG, default=global_settings.TEMPLATE_DEBUG, ) TEMPLATE_DIRS = colander.SchemaNode( colander.Sequence(), missing=global_settings.TEMPLATE_DIRS, default=global_settings.TEMPLATE_DIRS, children=[ colander.SchemaNode(colander.String()), ] ) TEMPLATE_LOADERS = colander.SchemaNode( colander.List(), missing=global_settings.TEMPLATE_LOADERS, default=global_settings.TEMPLATE_LOADERS, children=[ colander.SchemaNode(colander.String()), ] ) TEMPLATE_STRING_IF_INVALID = colander.SchemaNode( colander.String(), missing=global_settings.TEMPLATE_STRING_IF_INVALID, default=global_settings.TEMPLATE_STRING_IF_INVALID, ) TEST_NON_SERIALIZED_APPS = colander.SchemaNode( colander.Sequence(), missing=global_settings.TEST_NON_SERIALIZED_APPS, default=global_settings.TEST_NON_SERIALIZED_APPS, children=[ colander.SchemaNode(colander.String()), ] ) TEST_RUNNER = colander.SchemaNode( colander.String(), missing=global_settings.TEST_RUNNER, default=global_settings.TEST_RUNNER, ) THOUSAND_SEPARATOR = colander.SchemaNode( colander.String(), missing=global_settings.THOUSAND_SEPARATOR, default=global_settings.THOUSAND_SEPARATOR, ) TIME_FORMAT = colander.SchemaNode( colander.String(), missing=global_settings.TIME_FORMAT, default=global_settings.TIME_FORMAT, ) TIME_INPUT_FORMATS = colander.SchemaNode( colander.Sequence(), missing=global_settings.TIME_INPUT_FORMATS, default=global_settings.TIME_INPUT_FORMATS, children=[ colander.SchemaNode(colander.String()), ] ) TIME_ZONE = colander.SchemaNode( colander.String(), missing=global_settings.TIME_ZONE, default=global_settings.TIME_ZONE, ) TRANSACTIONS_MANAGED = colander.SchemaNode( colander.Boolean(), missing=global_settings.TRANSACTIONS_MANAGED, default=global_settings.TRANSACTIONS_MANAGED, ) USE_ETAGS = colander.SchemaNode( colander.Boolean(), missing=global_settings.USE_ETAGS, default=global_settings.USE_ETAGS, ) USE_I18N = colander.SchemaNode( colander.Boolean(), missing=global_settings.USE_I18N, default=global_settings.USE_I18N, ) USE_L10N = colander.SchemaNode( colander.Boolean(), missing=global_settings.USE_L10N, default=global_settings.USE_L10N, ) USE_THOUSAND_SEPARATOR = colander.SchemaNode( colander.Boolean(), missing=global_settings.USE_THOUSAND_SEPARATOR, default=global_settings.USE_THOUSAND_SEPARATOR, ) USE_TZ = colander.SchemaNode( colander.Boolean(), missing=global_settings.USE_TZ, default=global_settings.USE_TZ, ) USE_X_FORWARDED_HOST = colander.SchemaNode( colander.Boolean(), missing=global_settings.USE_X_FORWARDED_HOST, default=global_settings.USE_X_FORWARDED_HOST, ) WSGI_APPLICATION = colander.SchemaNode( colander.String(), missing=global_settings.WSGI_APPLICATION, default=global_settings.WSGI_APPLICATION, ) YEAR_MONTH_FORMAT = colander.SchemaNode( colander.String(), missing=global_settings.YEAR_MONTH_FORMAT, default=global_settings.YEAR_MONTH_FORMAT, ) X_FRAME_OPTIONS = colander.SchemaNode( colander.String(), missing=global_settings.X_FRAME_OPTIONS, default=global_settings.X_FRAME_OPTIONS, )
def test_get_colander_keys_from_node_names(self): friend = colander.SchemaNode(colander.Tuple()) friend.add(colander.SchemaNode(colander.Int(), validator=colander.Range(0, 9999), name='rank')) friend.add(colander.SchemaNode(colander.Int(), name='foo')) assert_equal(http.get_colander_keys(friend), ['rank', 'foo'])
import colander friend = colander.SchemaNode(colander.Tuple()) friend.add( colander.SchemaNode(colander.Int(), validator=colander.Range(0, 9999), name='rank')) friend.add(colander.SchemaNode(colander.String(), name='name')) print(friend.typ) for each_p in friend: print(each_p.typ) phone = colander.SchemaNode( colander.Mapping(), colander.SchemaNode(colander.String(), validator=colander.OneOf(['home', 'work']), name='location')) phone.add(colander.SchemaNode(colander.String(), name='number')) print(phone.typ) for each_p in phone: print(each_p.typ) schema = colander.SchemaNode(colander.Mapping()) schema.add(colander.SchemaNode(colander.String(), name='name')) schema.add( colander.SchemaNode(colander.Int(), name='age', validator=colander.Range(0, 200))) schema.add(colander.SequenceSchema(friend, name='friends'))