view MoinMoin/groups/backends/ @ 4806:dcbdf7e5660d

Groups2009: to_backend_name and to_group_name methods were removed. If a backend needs group name mapping it must handle it internally.
author Dmitrijs Milajevs <>
date Sat, 13 Jun 2009 20:14:27 +0200
parents 6a109416e2b2
children ca8fcf330aa8
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):

    def _load_group(self):
        request = self.request

        members_final = set()
        member_groups = set()

        for member in self._backend._groups[]:
            if member in self._backend._groups:

        self.members = members_final
        self.member_groups = member_groups

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)