From 817eb8f0a1565a70474a16ba85b8ea1b92ec7fda Mon Sep 17 00:00:00 2001 From: hokuma Date: Sat, 1 Oct 2016 21:47:32 +0900 Subject: [PATCH 1/2] version is not required attribute --- nozama-cloudsearch-data/nozama/cloudsearch/data/document.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py b/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py index f865270..e6790a6 100644 --- a/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py +++ b/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py @@ -61,8 +61,6 @@ class DocSchema(formencode.Schema): #fields = FieldsSchema(not_empty=True) - version = validators.String(not_empty=True, strip=True) - type = validators.OneOf( ["add", "delete"], not_empty=True, strip=True, ) From 58e95bb5b51cfb3a8ecac3d136e527ff8ef0446f Mon Sep 17 00:00:00 2001 From: hokuma Date: Sat, 1 Oct 2016 22:27:28 +0900 Subject: [PATCH 2/2] keep validation for striping --- nozama-cloudsearch-data/nozama/cloudsearch/data/document.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py b/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py index e6790a6..dc6b357 100644 --- a/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py +++ b/nozama-cloudsearch-data/nozama/cloudsearch/data/document.py @@ -49,6 +49,7 @@ class FieldsSchema(formencode.Schema): allow_extra_fields = True +from datetime import datetime class DocSchema(formencode.Schema): """Validate the document and the add/remove operation. @@ -61,6 +62,8 @@ class DocSchema(formencode.Schema): #fields = FieldsSchema(not_empty=True) + version = validators.String(strip=True, if_missing=datetime.now().strftime('%s')) + type = validators.OneOf( ["add", "delete"], not_empty=True, strip=True, )