Skip to content

Commit

Permalink
object: fixes internal loader not being used in some scenarios.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lapa <chris@lapa.com.au>
  • Loading branch information
GusBricker committed Sep 20, 2018
1 parent da7170a commit 9d297e9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dynamo_store/object.py
Expand Up @@ -157,6 +157,10 @@ def delete(self, primary_key=None, config_loader=None):
if primary_key:
logger.debug('Found existing pk %s' % primary_key)

if not config_loader or not callable(config_loader):
if self.CONFIG_LOADER and callable(self.CONFIG_LOADER):
config_loader = self.CONFIG_LOADER

if self.store(shards=shards).delete(d, primary_key, config_loader=config_loader):
logger.debug('Storing pk %s' % primary_key)
setattr(self, '__primary_key', primary_key)
Expand All @@ -179,6 +183,10 @@ def save(self, primary_key=None, config_loader=None):
if primary_key:
logger.debug('Found existing pk %s' % primary_key)

if not config_loader or not callable(config_loader):
if self.CONFIG_LOADER and callable(self.CONFIG_LOADER):
config_loader = self.CONFIG_LOADER

key = self.store(shards=shards).write(d, primary_key=primary_key, config_loader=config_loader)
if key:
logger.debug('Storing pk %s' % key)
Expand All @@ -196,6 +204,10 @@ def load(cls, primary_key, config_loader=None, validate=True):
:param validate: Enable JSON Models field validation
:returns: cls object
"""
if not config_loader or not callable(config_loader):
if cls.CONFIG_LOADER and callable(cls.CONFIG_LOADER):
config_loader = cls.CONFIG_LOADER

success, data = cls.store(shards=[]).read(primary_key, config_loader=config_loader)
if not success:
raise Exception('Couldnt read from store using pk: %s' % primary_key)
Expand Down

0 comments on commit 9d297e9

Please sign in to comment.