fix overrides.zcml: set skin; fix resource indexing: avoid error when principal not found

This commit is contained in:
Helmut Merz 2024-10-04 14:45:40 +02:00
parent 76e189ac45
commit 2a689a871b
3 changed files with 11 additions and 5 deletions

View file

@ -84,8 +84,9 @@ def getInternalPrincipal(id, context=None, pau=None):
raise PrincipalLookupError(id)
def getPrincipalForUserId(id, context=None):
auth = component.getUtility(IAuthentication, context=context)
def getPrincipalForUserId(id, context=None, auth=None):
if auth is None:
auth = component.getUtility(IAuthentication, context=context)
try:
return auth.getPrincipal(id)
except PrincipalLookupError:

View file

@ -4,6 +4,8 @@
<!-- ZCML declarations to override the default definitions -->
<browser:defaultSkin name="Loops" />
<browser:containerViews
for="zope.app.folder.interfaces.IFolder"
contents="zope.ManageContent"

View file

@ -588,12 +588,15 @@ class IndexAttributes(object):
self.creators()).strip()
def creators(self):
from loops.organize.util import getPrincipalForUserId
cr = IZopeDublinCore(self.context).creators or []
pau = component.getUtility(IAuthentication)
pau = component.getUtility(IAuthentication, context=self.context)
creators = []
for c in cr:
principal = pau.getPrincipal(c)
if principal is not None:
principal = getPrincipalForUserId(c, auth=pau)
if principal is None:
creators.append(c)
else:
creators.append(principal.title)
return creators