def validate(self, value, key): if isinstance(self.foreign_class, str): self.foreign_class = import_util(self.foreign_class) if value: for obj in value: if not isinstance(obj,self.foreign_class): raise ValidationException( '{0}: This value ({1}) should be an instance of {2}.'.format( key, obj, self.foreign_class.__name__))
def test_import_util(self): klass = import_util('valley.mixins.VariableMixin') self.assertEqual('VariableMixin', klass.__name__)
def get_foreign_class(self): if isinstance(self.foreign_class, str): return import_util(self.foreign_class) return self.foreign_class
def get_enums(self): return [ i.enum for i in self._base_properties.values() if isinstance(i, import_util('pfunk.EnumField')) ]
def render(self, include_submit=True): template = import_util(self._template) return template.render(form=self, include_submit=include_submit)