Skip to content

Commit e8ce0e1

Browse files
authored
Merge pull request #4 from IdanHaim/RavenDB-6332
RavenDB-6332
2 parents c250492 + 8433c9e commit e8ce0e1

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pyravendb/connection/requests_factory.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, url, database, convention=None, api_key=None, force_get_topol
2929
self.convention = convention
3030
if self.convention is None:
3131
self.convention = DocumentConvention()
32-
self.headers = {"Accept": "application/json", "Has-Api-key": True if self.api_key is not None else False,
32+
self.headers = {"Accept": "application/json", "Has-Api-key": 'true' if self.api_key is not None else 'false',
3333
"Raven-Client-Version": "3.0.0.0"}
3434
self.replication_topology = IndexQueue()
3535
self.topology_change_counter = 0
@@ -186,10 +186,7 @@ def update_replication(self, topology_file):
186186
with open(topology_file, 'w+') as f:
187187
f.write(json.dumps(self.topology))
188188
self.replication_topology.queue.clear()
189-
for destination in self.topology["Destinations"]:
190-
self.replication_topology.put({"url": destination["Url"], "database": destination["Database"],
191-
"credentials": {"api_key": destination["ApiKey"],
192-
"domain": destination["Domain"]}})
189+
self._load_topology()
193190

194191
def check_replication_change(self, topology_file):
195192

@@ -220,15 +217,19 @@ def get_replication_topology(self):
220217
try:
221218
with open(topology_file, 'r') as f:
222219
self.topology = json.loads(f.read())
223-
for destination in self.topology["Destinations"]:
224-
self.replication_topology.put({"url": destination["Url"], "database": destination["Database"],
225-
"credentials": {"api_key": destination["ApiKey"],
226-
"domain": destination["Domain"]}})
220+
self._load_topology()
227221
except IOError:
228222
pass
229223

230224
self.check_replication_change(topology_file)
231225

226+
def _load_topology(self):
227+
for destination in self.topology["Destinations"]:
228+
if not destination["Disabled"] and not destination["IgnoredClient"]:
229+
self.replication_topology.put({"url": destination["Url"], "database": destination["Database"],
230+
"credentials": {"api_key": destination["ApiKey"],
231+
"domain": destination["Domain"]}})
232+
232233
def do_auth_request(self, api_key, oauth_source, second_api_key=None):
233234
api_name, secret = api_key.split('/', 1)
234235
tries = 1

0 commit comments

Comments
 (0)