Skip to content

Commit d2caea3

Browse files
committed
added on load
1 parent df63d08 commit d2caea3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pyArango/collection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class Collection_metaclass(type) :
132132
_validationDefault = {
133133
'on_save' : False,
134134
'on_set' : False,
135+
'on_load' : False,
135136
'allow_foreign_fields' : True
136137
}
137138

@@ -217,6 +218,7 @@ class Collection(with_metaclass(Collection_metaclass, object)) :
217218
_validation = {
218219
'on_save' : False,
219220
'on_set' : False,
221+
'on_load' : False,
220222
'allow_foreign_fields' : True
221223
}
222224

pyArango/document.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ def reset(self, collection, jsonFieldInit = {}) :
2323
self._id, self._rev, self._key = None, None, None
2424
self.URL = None
2525

26-
self.set(jsonFieldInit)
26+
if not self.collection._validation['on_load']:
27+
self.set(jsonFieldInit, validate=False)
28+
else :
29+
self.set(jsonFieldInit, validate=True)
30+
2731
self.modified = True
2832

2933
def setPrivates(self, fieldDict) :
@@ -43,12 +47,16 @@ def setPrivates(self, fieldDict) :
4347
self._id, self._rev, self._key = None, None, None
4448
self.URL = None
4549

46-
def set(self, fieldDict = None) :
50+
def set(self, fieldDict = None, validate = True) :
4751
"""Sets the document according to values contained in the dictinnary fieldDict. This will also set self._id/_rev/_key"""
4852

4953
if fieldDict and self._id is None :
5054
self.setPrivates(fieldDict)
5155

56+
if not validate :
57+
self._store.update(fieldDict)
58+
return
59+
5260
if self.collection._validation['on_set']:
5361
for k in list(fieldDict.keys()) :
5462
self[k] = fieldDict[k]

0 commit comments

Comments
 (0)