return r
-class RodelbahnboxTemplateDict(formencode.Validator):
- """Private helper class for RodelbahnboxValidator"""
+class WinterrodelnTemplateDict(formencode.Validator):
+ """Private helper class for RodelbahnboxValidator or GasthausboxValidator"""
+ def __init__(self, template_title):
+ self.template_title = template_title
+
def to_python(self, value, state):
title, anonym_params, named_params = value
- if title != u'Rodelbahnbox':
- raise Invalud('Template title has to be "Rodelbahnbox".', value, state)
+ if title != self.template_title:
+ raise Invalud(u'Template title has to be "{}".'.format(self.template_title), value, state)
if len(anonym_params) > 0:
- raise Invalid('No anonymous parameters are allowed in "Rodelbahnbox".', value, state)
+ raise Invalid(u'No anonymous parameters are allowed in "{}".'.format(self.template_title), value, state)
return named_params
def from_python(self, value, state):
- return u'Rodelbahnbox', [], value
+ return self.template_title, [], value
class RodelbahnboxValidator(wrpylib.wrvalidators.RodelbahnboxDictValidator):
def __init__(self):
wrpylib.wrvalidators.RodelbahnboxDictValidator.__init__(self)
- self.pre_validators=[wrpylib.mwmarkup.TemplateValidator(as_table=True, as_table_keylen=20), RodelbahnboxTemplateDict()]
+ self.pre_validators=[wrpylib.mwmarkup.TemplateValidator(as_table=True, as_table_keylen=20), WinterrodelnTemplateDict(u'Rodelbahnbox')]
self.chained_validators = [RodelbahnboxDictConverter()]