trolldbois / python-haystack

Process heap analysis framework - Windows/Linux - record type inference and forensics
http://trolldbois.blogspot.com/search?q=python-haystack
GNU General Public License v3.0
94 stars 33 forks source link

search API: modify listmodel to use a record type base validator/loader constraints Interface #18

Closed trolldbois closed 8 years ago

trolldbois commented 8 years ago

to have advanced constraints and loading available in the search API, we would need to supplement the basic/listmodel with hooks to call registered validator classes at the is_valid invocation. registration should be done by a dict("record_type_name": validator class)

Example: The validator class init still cannot register list fields as its a listModel duty. But the validator class could have a callback method that will be called by listModel at registration time def init_validator(self, listmodel_validator): pass

the is_valid method could calculate inter-field constraints or more complex constraints on field. Depending on a validator flag value, Is_valid would be called before or after or inplace of the basicmodel is_valid. methods = [self.is_valid, validator.is_valid] or methods = [validator.is_valid, self.is_valid] [..] for m in methods: ret = m() if not ret: return False return True

No load_members override.

listmodel should be modified directly. usage of the list methods are just complex without this.