diff --git a/knowledge/survey/base.py b/knowledge/survey/base.py index 7e2ebd1..a9fb732 100644 --- a/knowledge/survey/base.py +++ b/knowledge/survey/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2013 Helmut Merz helmutm@cy55.de +# Copyright (c) 2015 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,6 +46,9 @@ class Questionnaire(AdapterBase, Questionnaire): @property def questionGroups(self): + return self.getQuestionGroups() + + def getQuestionGroups(self): return [adapted(c) for c in self.context.getChildren()] @property diff --git a/organize/party.py b/organize/party.py index 7cfd52c..fbb879c 100644 --- a/organize/party.py +++ b/organize/party.py @@ -24,6 +24,7 @@ from persistent.mapping import PersistentMapping from zope import interface, component from zope.app.principalannotation import annotations from zope.app.security.interfaces import IAuthentication, PrincipalLookupError +from zope.app.security.interfaces import IUnauthenticatedPrincipal from zope.component import adapts from zope.interface import implements from zope.cachedescriptors.property import Lazy @@ -44,6 +45,7 @@ from loops.predicate import RelationAdapter from loops.predicate import PredicateInterfaceSourceList from loops.security.common import assignOwner, removeOwner, allowEditingForOwner from loops.security.common import assignPersonRole, removePersonRole +from loops.security.common import getCurrentPrincipal from loops.security.interfaces import ISecuritySetter from loops.type import TypeInterfaceSourceList from loops import util @@ -59,7 +61,10 @@ def getPersonForUser(context, request=None, principal=None): if context is None: return None if principal is None: - principal = getattr(request, 'principal', None) + if request is not None: + principal = getattr(request, 'principal', None) + else: + principal = getPrincipal(context) if principal is None: return None loops = context.getLoopsRoot() @@ -74,6 +79,15 @@ def getPersonForUser(context, request=None, principal=None): return pa.get(util.getUidForObject(loops)) +def getPrincipal(context): + principal = getCurrentPrincipal() + if principal is not None: + if IUnauthenticatedPrincipal.providedBy(principal): + return None + return principal + return None + + class Person(AdapterBase, BasePerson): """ typeInterface adapter for concepts of type 'person'. """