From 469f24d113ac8c7b634026d3291cbe14fdc93eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 13 Jul 2018 17:13:26 +0200 Subject: [PATCH] Fix for {validate: markdown} when used in Eve Eve's Validator has not only a validate() function, but also validate_update() and validate_replace(). Those set self.persisted_document, so if that attribute exists we just use it. --- pillar/api/custom_field_validation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pillar/api/custom_field_validation.py b/pillar/api/custom_field_validation.py index f5f1cc31..b6d9143e 100644 --- a/pillar/api/custom_field_validation.py +++ b/pillar/api/custom_field_validation.py @@ -180,6 +180,9 @@ class ValidateCustomFields(Validator): """ # Find this field inside the original document my_subdoc = self._subdoc_in_real_document() + if my_subdoc is None: + self._error(field, f'unable to find sub-document for path {self.document_path}') + return save_to = pillar.markdown.cache_field_name(field) html = pillar.markdown.markdown(value) @@ -190,7 +193,7 @@ class ValidateCustomFields(Validator): This allows modification of the document being validated. """ - my_subdoc = self.__real_document + my_subdoc = getattr(self, 'persisted_document') or self.__real_document for item in self.document_path: my_subdoc = my_subdoc[item] return my_subdoc