[Zope3-dev] Bug Tracker
Imaappppp
riccardo.tonon at srlabs.it
Wed Jul 6 06:32:41 EDT 2005
Hi,
In the bugtracker/vocabulary.py I'm getting errors like:
'PluggableAuthentication' object has no attribute 'getPrincipals'
# From src/bugtracker/vocabulary.py
class UserTerm(Persistent):
implements(ITitledTokenizedTerm)
def __init__(self, principal):
# This is safe here, since we only read non-critical data
naked = removeSecurityProxy(principal)
self.principal = {'id': naked.id,
'login': naked.getLogin(),
'title': naked.title,
'description': naked.description}
self.value = naked.id
self.token = naked.id
self.title = naked.title
class UserVocabulary(object):
implements(IVocabulary, IVocabularyTokenized)
def __init__(self, context):
self.auth = zapi.principals()
def __contains__(self, value):
ids = map(lambda p: p.id, self.auth.getPrincipals(''))
return value in ids
def __iter__(self):
terms = map(lambda p: UserTerm(p), self.auth.getPrincipals(''))
return iter(terms)
def __len__(self):
return len(self.auth.getPrincipals(''))
def getQuery(self):
return None
def getTerm(self, value):
return UserTerm(self.auth.getPrincipal(value))
def getTermByToken(self, token):
return self.getTerm(token)
I'm not interested in having principals that are not in an userfolder in
the bugtracker, so I converted it to:
class UserTerm(Persistent):
implements(ITitledTokenizedTerm)
def __init__(self, principal):
# This is safe here, since we only read non-critical data
naked = removeSecurityProxy(principal)
self.principal = {'id': naked.id,
'login': naked.id,
'title': naked.title,
'description': naked.description}
self.value = naked.id
self.token = naked.id
self.title = naked.title
class UserVocabulary(object):
implements(IVocabulary, IVocabularyTokenized)
def __init__(self, context):
self.auth = zapi.principals()
def __contains__(self, value):
# let's get the keys in the userfolders
ids = [principal for queriable in self.auth.getQueriables() for
principal in queriable[1]]
return value in ids
def __iter__(self):
terms = [ UserTerm(self.auth.getPrincipal(principal)) for
queriable in self.auth.getQueriables() for principal in queriable[1]]
return iter(terms)
def __len__(self):
return len([principal for queriable in self.auth.getQueriables()
for principal in queriable[1]])
def getQuery(self):
return None
def getTerm(self, value):
return UserTerm(self.auth.getPrincipal(value))
def getTermByToken(self, token):
return self.getTerm(token)
It's a big hack, BUT at least works, and turns the bugtracker online
again! Suggestions for a better fix?
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-dev/attachments/20050706/14f1ed08/attachment.htm
More information about the Zope3-dev
mailing list