File: config_lazy_groups.py

package info (click to toggle)
moin 1.9.9-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 76,024 kB
  • sloc: python: 143,896; java: 10,704; php: 2,385; perl: 1,574; xml: 371; makefile: 214; sh: 81; sed: 5
file content (43 lines) | stat: -rw-r--r-- 1,164 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: iso-8859-1 -*-
"""
    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.

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

from MoinMoin.datastruct.backends import LazyGroup, LazyGroupsBackend


class ConfigLazyGroup(LazyGroup):
    pass


class ConfigLazyGroups(LazyGroupsBackend):

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

        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(self.request, 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]