avoid error when no groups folder is found (e.g. in doctests)

This commit is contained in:
Helmut Merz 2017-08-02 08:53:12 +02:00
parent 63220a656f
commit 7a3cfbc175

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
# Copyright (c) 2017 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
@ -134,6 +134,8 @@ def getGroupsForPrincipal(principal=None):
if principal is None:
principal = getCurrentPrincipal()
gf = getGroupsFolder()
if gf is None:
return []
prefix = 'gloops.'
return [(g.startswith(prefix) and g[len(prefix):] or g)
for g in gf.getGroupsForPrincipal(principal.id)]