def tooLoud(value): # import pdb; pdb.set_trace() # Attempting to read value blows up! return _(u"Yuck! Too loud")
def checkDates(data): if data.start is not None and data.end is not None: if data.start > data.end: raise StartBeforeEnd(_(u"The start date must be before the end date."))
def validateTitle(value): if value and value == value.upper(): raise schema.interfaces.InvalidValue(_(u"Please don't shout"))
def validate(self, value): if value and not '@' in value: raise Invalid(_(u"Missing @!"))
class ISession(form.Schema, IImageScaleTraversable): """ Conference Session """ title = schema.TextLine(title=_(u'Session Name')) description = schema.Text( title=_(u'Session summary'), description=_(u'Short description of session topics'), ) start = schema.Datetime( title=_(u'Session starts'), defaultFactory=default_start, ) end = schema.Datetime(title=_(u'Session ends'), defaultFactory=default_end) accessible = schema.Choice( title=_(u'Accessible?'), values=(_(u'Yes'), _(u'No')), default='Yes', ) form.widget(accessible="z3c.form.browser.radio.RadioFieldWidget") tracks = schema.List( title=_(u'Tracks for this session'), value_type=schema.Choice(title=u'dummy', source=trackVocabulary), ) searchable('details') details = RichText(title=_(u'Details')) presenters = RelationList( title=u"Presenters", default=[], value_type=RelationChoice( title=_(u"Presenter"), source=ObjPathSourceBinder( object_provides= 'collective.dexterity_class.presenter.IPresenter')), required=False, ) @invariant def checkDates(data): if data.start is not None and data.end is not None: if data.start > data.end: raise StartBeforeEnd( _(u"The start date must be before the end date."))
class StartBeforeEnd(Invalid): __doc__ = _(u"The start or end date is invalid")
def checkDates(data): if data.start is not None and data.end is not None: if data.start > data.end: raise StartBeforeEnd( _(u"The start date must be before the end date."))