Skip to content

Commit e7dfe6b

Browse files
author
Roland Hedberg
committed
A second any method that is faster then the first.
1 parent e1432e0 commit e7dfe6b

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/saml2/mdstore.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def any(self, typ, service, binding=None):
269269
"""
270270
Return any entity that matches the specification
271271
272-
:param typ:
272+
:param typ: Type of entity
273273
:param service:
274274
:param binding:
275275
:return:
@@ -282,6 +282,37 @@ def any(self, typ, service, binding=None):
282282

283283
return res
284284

285+
def any2(self, typ, service, binding=None):
286+
"""
287+
288+
:param type:
289+
:param service:
290+
:param binding:
291+
:return:
292+
"""
293+
res = {}
294+
for entid, item in self.items():
295+
hit = False
296+
try:
297+
descr = item['{}sso_descriptor'.format(typ)]
298+
except KeyError:
299+
continue
300+
else:
301+
for desc in descr:
302+
try:
303+
srvs = desc[service]
304+
except KeyError:
305+
continue
306+
else:
307+
for srv in srvs:
308+
if srv['binding'] == binding:
309+
res[entid] = item
310+
hit = True
311+
break
312+
if hit:
313+
break
314+
return res
315+
285316
def bindings(self, entity_id, typ, service):
286317
"""
287318
Get me all the bindings that are registered for a service entity

0 commit comments

Comments
 (0)