Skip to content

Commit

Permalink
make it easier to recompute the natural key hash
Browse files Browse the repository at this point in the history
  • Loading branch information
zbyte64 committed Apr 2, 2013
1 parent 9813efb commit 64e0d94
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dockit/schema/schema.py
Expand Up @@ -455,10 +455,13 @@ def get_or_create_natural_key(self, refresh=False):
if refresh or not self._primitive_data.get('@natural_key', None):
self._primitive_data['@natural_key'] = self.create_natural_key()
self._primitive_data.pop('@natural_key_hash', None)
if refresh or '@natural_key_hash' not in self._primitive_data:
self._primitive_data['@natural_key_hash'] = self._get_natural_key_hash(self._primitive_data['@natural_key'])
if refresh or not self._primitive_data.get('@natural_key_hash', None):
self.set_natural_key_hash()
return self._primitive_data['@natural_key']

def set_natural_key_hash(self):
self._primitive_data['@natural_key_hash'] = self._get_natural_key_hash(self._primitive_data['@natural_key'])

def create_natural_key(self):
'''
Documents may want to override this to return a dictionary of values representing the natural key of the document.
Expand Down

0 comments on commit 64e0d94

Please sign in to comment.