Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(29)  |  Call(22)  |  Derive(0)  |  Import(7)
Factory for creating i18n messages.

src/p/r/Products.validation-2.0/Products/validation/validators/SupplValidators.py   Products.validation(Download)
from Products.validation.interfaces.IValidator import IValidator
from zope.interface import implements
from Products.validation.i18n import PloneMessageFactory as _
from Products.validation.i18n import recursiveTranslate
from Products.validation.i18n import safe_unicode
 
        if sizeMB > maxsize:
            msg = _("Validation failed($name: Uploaded data is too large: ${size}MB (max ${max}MB)",
                    mapping = {
                        'name' : safe_unicode(self.name),
    def __call__(self, value, *args, **kwargs):
        if not value:
            msg = _(u"Validation failed($name): value is empty ($value).",
                   mapping = {'name': self.name, 'value': repr(value)})
            return recursiveTranslate(msg, **kwargs)
        if not isinstance(value, DateTime):
            try:
                value = DateTime(value)
            except:
                msg = _(u"Validation failed($name): could not convert $value to a date.",

src/p/r/Products.validation-2.0/Products/validation/validators/RegexValidator.py   Products.validation(Download)
from Products.validation.interfaces.IValidator import IValidator
from zope.interface import implements
from Products.validation.i18n import PloneMessageFactory as _
from Products.validation.i18n import recursiveTranslate
from Products.validation.i18n import safe_unicode
    def __call__(self, value, *args, **kwargs):
        if type(value) != StringType:
            msg =  _(u"Validation failed($name): $value of type $type, expected 'string'",
                     mapping = {
                        'name' : safe_unicode(self.name),
            m = r.match(value)
            if not m:
                msg =  _(u"Validation failed($name): '$value' $errmsg",
                         mapping={
                            'name' : safe_unicode(self.name),

src/p/r/Products.validation-2.0/Products/validation/validators/RangeValidator.py   Products.validation(Download)
from Products.validation.interfaces.IValidator import IValidator
from zope.interface import implements
from Products.validation.i18n import PloneMessageFactory as _
from Products.validation.i18n import recursiveTranslate
from Products.validation.i18n import safe_unicode
            nval = float(value)
        except ValueError:
            msg = _(u"Validation failed($name): could not convert '$value' to number",
                    mapping = { 'name' : safe_unicode(self.name), 'value': safe_unicode(value)})
            return recursiveTranslate(msg, **kwargs)
        if minval <= nval < maxval:
            return 1
 
        msg = _(u"Validation failed($name): '$value' out of range($min, $max)",

src/p/r/Products.validation-2.0/Products/validation/validators/IdValidator.py   Products.validation(Download)
from Products.validation.interfaces.IValidator import IValidator
from zope.interface import implements
from Products.validation.i18n import PloneMessageFactory as _
from Products.validation.i18n import recursiveTranslate
from Products.validation.i18n import safe_unicode
            # space test
            if ' ' in id:
                msg =  _(u'Spaces are not allowed in ids')
                return recursiveTranslate(msg, **kwargs)
 
            # in parent test
            parent = aq_parent(aq_inner(instance))
            # If the id is given to a different object already
            if id in parent.objectIds() and getattr(aq_base(parent), id) is not aq_base(instance):
                msg = _(u'Id $id is already in use',

src/p/r/Products.validation-2.0/Products/validation/validators/ExpressionValidator.py   Products.validation(Download)
 
from Products.validation.interfaces.IValidator import IValidator
from Products.validation.i18n import PloneMessageFactory as _
from Products.validation.i18n import recursiveTranslate
from Products.validation.i18n import safe_unicode
                return self.errormsg % kw
            else:
                msg = _(u'validation failed, expr was:$expr',
                        mapping={'expr': safe_unicode(self.expression)})
                return recursiveTranslate(msg, **kwargs)

src/p/r/Products.validation-2.0/Products/validation/validators/EmptyValidator.py   Products.validation(Download)
from zope.interface import implements
from Products.validation.i18n import PloneMessageFactory as _
from Products.validation.i18n import recursiveTranslate
from Products.validation.i18n import safe_unicode
from Products.validation.interfaces.IValidator import IValidator
        else:
            if getattr(self, 'showError', False):
                msg =  _(u"Validation failed($name): '$value' is not empty.",
                         mapping = { 'name' : safe_unicode(self.name), 'value': safe_unicode(value)})
                return recursiveTranslate(msg, **kwargs)

src/p/r/Products.validation-2.0/Products/validation/validators/BaseValidators.py   Products.validation(Download)
from RegexValidator import RegexValidator
from RangeValidator import RangeValidator
from Products.validation.i18n import PloneMessageFactory as _
 
# protocols for isURL validator, the secure (*s) variants are automagically
                   r'^([+-]?)(?=\d|(\.|\,)\d)\d*((\,|\.)\d*)?([Ee]([+-]?\d+))?$',
                   title='', description='',
                   errmsg=_(u'is not a decimal number.')),
    RegexValidator('isInt', r'^([+-])?\d+$', title='', description='',
                   errmsg=_(u'is not an integer.')),
    RegexValidator('isPrintable', r'[a-zA-Z0-9\s]+$', title='', description='',
                   errmsg=_(u'contains unprintable characters')),
    RegexValidator('isSSN', r'^\d{9}$', title='', description='',
                   errmsg=_(u'is not a well formed SSN.')),