Skip to content

Commit

Permalink
ReviewFix: always use primary for has_symbol, it's safer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward J M Easton committed Sep 1, 2015
1 parent e7e2700 commit e20cc85
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions arctic/store/version_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def list_symbols(self, all_symbols=False, snapshot=None, regex=None, **kwargs):
return sorted([x['symbol'] for x in results])

@mongo_retry
def has_symbol(self, symbol, as_of=None, allow_secondary=None):
def has_symbol(self, symbol, as_of=None):
"""
Return True if the 'symbol' exists in this library AND the symbol
isn't deleted in the specified as_of.
Expand All @@ -188,14 +188,10 @@ def has_symbol(self, symbol, as_of=None, allow_secondary=None):
`int` : specific version number
`str` : snapshot name which contains the version
`datetime.datetime` : the version of the data that existed as_of the requested point in time
allow_secondary : `bool` or `None`
Override the default behavior for allowing reads from secondary members of a cluster:
`None` : use the settings from the top-level `Arctic` object used to query this version store.
`True` : allow reads from secondary members
`False` : only allow reads from primary members
"""
try:
self._read_metadata(symbol, as_of=as_of, read_preference=self._read_preference(allow_secondary))
# Always use the primary for has_symbol, it's safer
self._read_metadata(symbol, as_of=as_of, read_preference=ReadPreference.PRIMARY)
return True
except NoDataFoundException:
return False
Expand Down Expand Up @@ -667,7 +663,7 @@ def delete(self, symbol):
'metadata.deleted': {'$ne': True}})
if not snapped_version:
self._delete_version(symbol, sentinel.version)
assert not self.has_symbol(symbol, allow_secondary=False)
assert not self.has_symbol(symbol)

def _write_audit(self, user, message, changed_version):
"""
Expand Down

0 comments on commit e20cc85

Please sign in to comment.