Skip to content

Instantly share code, notes, and snippets.

@oleiade
Created October 4, 2012 09:18
Show Gist options
  • Save oleiade/3832469 to your computer and use it in GitHub Desktop.
Save oleiade/3832469 to your computer and use it in GitHub Desktop.
MGet
def MGet(self, db, keys, fill_cache=True, *args, **kwargs):
def get_or_none(key, context):
try:
res = db.Get(key, fill_cache=fill_cache)
except KeyError:
warning_msg = "Key {0} does not exist".format(key)
context.update({'status': WARNING_STATUS})
self.errors_logger.warning(warning_msg)
res = None
return res
context = {'status': SUCCESS_STATUS}
value = [(key, get_or_none(key, context)) for key in keys]
status = context['status']
return status, value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment