def getQueriables(self): """Returns an iteratable of queriables. Queriables are responsible for providing interfaces to search for principals by a set of given parameters (can be different for the various queriables). This method will walk up through all of the authentication utilities to look for queriables. >>> from zope.schema.interfaces import ISourceQueriables >>> @implementer(IAuthentication) ... class DummyUtility1(object): ... __parent__ = None ... def __repr__(self): return 'dummy1' >>> dummy1 = DummyUtility1() >>> @implementer(ISourceQueriables, IAuthentication) ... class DummyUtility2(object): ... __parent__ = None ... def getQueriables(self): ... return ('1', 1), ('2', 2), ('3', 3) >>> dummy2 = DummyUtility2() >>> @implementer(IAuthentication) ... class DummyUtility3(DummyUtility2): ... def getQueriables(self): ... return ('4', 4), >>> dummy3 = DummyUtility3() >>> from zope.authentication.tests.utils import testingNextUtility >>> testingNextUtility(dummy1, dummy2, IAuthentication) >>> testingNextUtility(dummy2, dummy3, IAuthentication) >>> from zope.component import provideUtility >>> provideUtility(dummy1) >>> from zope.authentication.principal import PrincipalSource >>> source = PrincipalSource() >>> list(source.getQueriables()) [(u'0', dummy1), (u'1.1', 1), (u'1.2', 2), (u'1.3', 3), (u'2.4', 4)] """ i = 0 auth = getUtility(IAuthentication) yielded = [] while True: queriables = ISourceQueriables(auth, None) if queriables is None: yield unicode(i), auth else: for qid, queriable in queriables.getQueriables(): # ensure that we dont return same yielded utility more # then once if queriable not in yielded: yield unicode(i)+'.'+unicode(qid), queriable yielded.append(queriable) auth = queryNextUtility(auth, IAuthentication) if auth is None: break i += 1
def getQueriables(self): """Returns an iteratable of queriables. Queriables are responsible for providing interfaces to search for principals by a set of given parameters (can be different for the various queriables). This method will walk up through all of the authentication utilities to look for queriables. >>> class DummyUtility1: ... implements(IAuthentication) ... __parent__ = None ... def __repr__(self): return 'dummy1' >>> dummy1 = DummyUtility1() >>> class DummyUtility2: ... implements(ISourceQueriables, IAuthentication) ... __parent__ = None ... def getQueriables(self): ... return ('1', 1), ('2', 2), ('3', 3) >>> dummy2 = DummyUtility2() >>> class DummyUtility3(DummyUtility2): ... implements(IAuthentication) ... def getQueriables(self): ... return ('4', 4), >>> dummy3 = DummyUtility3() >>> from zope.component.nexttesting import testingNextUtility >>> testingNextUtility(dummy1, dummy2, IAuthentication) >>> testingNextUtility(dummy2, dummy3, IAuthentication) >>> from zope.component import provideUtility >>> provideUtility(dummy1) >>> source = PrincipalSource() >>> list(source.getQueriables()) [(u'0', dummy1), (u'1.1', 1), (u'1.2', 2), (u'1.3', 3), (u'2.4', 4)] """ i = 0 auth = getUtility(IAuthentication) yielded = [] while True: queriables = ISourceQueriables(auth, None) if queriables is None: yield unicode(i), auth else: for qid, queriable in queriables.getQueriables(): # ensure that we dont return same yielded utility more # then once if queriable not in yielded: yield unicode(i) + '.' + unicode(qid), queriable yielded.append(queriable) auth = queryNextUtility(auth, IAuthentication) if auth is None: break i += 1
def queryviews(self): queriables = ISourceQueriables(self.source, None) if queriables is None: # treat the source itself as a queriable queriables = ((self.name + '.query', self.source), ) else: queriables = [(self.name + '.' + safeBase64Encode(i), s) for (i, s) in queriables.getQueriables()] return [(name, getMultiAdapter( (source, self.request), ISourceQueryView, )) for (name, source) in queriables]
def queryviews(self): queriables = ISourceQueriables(self.source, None) if queriables is None: # treat the source itself as a queriable queriables = ((self.name + '.query', self.source), ) else: queriables = [ (self.name + '.' + safeBase64Encode(i), s) for (i, s) in queriables.getQueriables()] return [ (name, getMultiAdapter( (source, self.request), ISourceQueryView, ) ) for (name, source) in queriables]
def queryviews(self): queriables = ISourceQueriables(self.source, None) if queriables is None: # treat the source itself as a queriable queriables = ((self.name + '.query', self.source), ) else: queriables = [ (self.name + '.' + unicode(i).encode('base64').strip().replace('=', '_'), s) for (i, s) in queriables.getQueriables()] return [ (name, getMultiAdapter( (source, self.request), ISourceQueryView, ) ) for (name, source) in queriables]
def queryviews(self): queriables = ISourceQueriables(self.source, None) if queriables is None: # treat the source itself as a queriable queriables = ((self.name + '.query', self.source), ) else: queriables = [ (self.name + '.' + unicode(i).encode('base64').strip().replace('=', '_'), s) for (i, s) in queriables.getQueriables() ] return [(name, getMultiAdapter( (source, self.request), zope.formlibwidget.browser.interfaces.ISourceQueryView, )) for (name, source) in queriables]