view MoinMoin/datastruct/backends/ @ 1364:582e7109a8c1

mass update - delete trailing spaces and/or add blank line to end of file
author Roger Haase <>
date Wed, 06 Jun 2012 15:03:07 -0700
parents 4cd8edde9e94
children 4ac437141bbe
line wrap: on
line source
# Copyright: 2009 MoinMoin:DmitrijsMilajevs
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

    MoinMoin - config group lazy backend.

    The config group backend allows one to define groups in a
    configuration file.

    NOTE that this is proof-of-concept implementation. LDAP backend
    should be based on this concept.

from MoinMoin.datastruct.backends import LazyGroup, LazyGroupsBackend

class ConfigLazyGroup(LazyGroup):

class ConfigLazyGroups(LazyGroupsBackend):

    def __init__(self, groups):
        super(ConfigLazyGroups, self).__init__()

        self._groups = groups

    def __contains__(self, group_name):
        return group_name in self._groups

    def __iter__(self):
        return self._groups.iterkeys()

    def __getitem__(self, group_name):
        return ConfigLazyGroup(group_name, self)

    def _iter_group_members(self, group_name):
        if group_name in self:
            return self._groups[group_name].__iter__()

    def _group_has_member(self, group_name, member):
        return group_name in self and member in self._groups[group_name]