view MoinMoin/groups/backends/ @ 4807:ca8fcf330aa8

Groups2009: Backend's _retrieve_members and is_group methods were introduced. _load_group became method of a BaseGroup to avoid code repetition. Test for empty group was added.
author Dmitrijs Milajevs <>
date Sat, 13 Jun 2009 20:44:06 +0200
parents dcbdf7e5660d
children 415338464695
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
MoinMoin - config group backend

The config group backend enables you to define groups in a configuration file.

@copyright: 2009 MoinMoin:DmitrijsMilajevs
@license: GPL, see COPYING for details

from MoinMoin.groups.backends import BaseGroup, BaseBackend

class Group(BaseGroup):

class Backend(BaseBackend):

    def __init__(self, request, groups):
        @param groups: Dictionary of groups where key is group name,
        and value is list of members of that group.
        super(Backend, self).__init__(request)

        self._groups = groups

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

    def __iter__(self):
        return iter(self._groups.keys())

    def __getitem__(self, group_name):
        return Group(request=self.request, name=group_name, backend=self)

    def _retrieve_members(self, group_name):
        return self._groups[group_name]