def valid_xml_schema(xml): if not xml or xml == DEFAULT_MODEL_XML: return True # bypass try: return loadString(xml) except ExpatError: raise schema.ValidationError('could not parse field schema xml') return True
def add(self, data): name = data['connname'].strip() if str(name) in self.storage: msg = _(u'error_name_already_registered', u'The connection name is already registered') msg = translate(msg, self.request) raise schema.ValidationError(msg) self.storage[name] = data['connstring'].strip() return ConnectionLine(name, data['connstring'].strip(), self)
def fromUnicode(self, u): name = str(u.strip()) # special case, mostly for interfaces if name == '*': return None try: value = self.context.resolve(name) except ConfigurationError, v: raise schema.ValidationError(v)
def add(self, data): secret = collective.singing.subscribe.secret(self.context, self.composer, data, self.request) composer_data = dict([(name, value) for (name, value) in data.items() if name in self._composer_fields()]) collector_data = dict([(name, value) for (name, value) in data.items() if name in self._collector_fields()]) metadata = dict(format=self.format, date=datetime.datetime.now()) try: return aq_inner(self.context).subscriptions.add_subscription( self.context, secret, composer_data, collector_data, metadata) except ValueError, e: raise schema.ValidationError(e.args[0])
def validate_field1_context(value): if value == 'fail': raise schema.ValidationError(u"Field 1, context")
def validate_field1_secondary(value): if value == 'fail': raise schema.ValidationError(u"Field 1, form 2")
def validate_field1(value): if value == 'fail': raise schema.ValidationError(u"Field 1, form 1")
def _validate(self, value): super(PythonIdentifier, self)._validate(value) if pyidentifierPattern.match(value) is None: raise schema.ValidationError(value)
def maxSize(value): if value is not None: if len(value) / 1024 > 128: raise schema.ValidationError( _(u"message text must be smaller than 128KB"))
def validateDescription(value): if 'php' in value.lower(): raise schema.ValidationError(u"PHP is not for mature audiences.")