~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/datastruct/backends/config_lazy_groups.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: iso-8859-1 -*-
2
 
"""
3
 
    MoinMoin - config group lazy backend.
4
 
 
5
 
    The config group backend allows one to define groups in a
6
 
    configuration file.
7
 
 
8
 
    NOTE that this is proof-of-concept implementation. LDAP backend
9
 
    should be based on this concept.
10
 
 
11
 
    @copyright: 2009 MoinMoin:DmitrijsMilajevs
12
 
    @license: GPL, see COPYING for details
13
 
"""
14
 
 
15
 
from MoinMoin.datastruct.backends import LazyGroup, LazyGroupsBackend
16
 
 
17
 
 
18
 
class ConfigLazyGroup(LazyGroup):
19
 
    pass
20
 
 
21
 
 
22
 
class ConfigLazyGroups(LazyGroupsBackend):
23
 
 
24
 
    def __init__(self, request, groups):
25
 
        super(ConfigLazyGroups, self).__init__(request)
26
 
 
27
 
        self._groups = groups
28
 
 
29
 
    def __contains__(self, group_name):
30
 
        return group_name in self._groups
31
 
 
32
 
    def __iter__(self):
33
 
        return self._groups.iterkeys()
34
 
 
35
 
    def __getitem__(self, group_name):
36
 
        return ConfigLazyGroup(self.request, group_name, self)
37
 
 
38
 
    def _iter_group_members(self, group_name):
39
 
        if group_name in self:
40
 
            return self._groups[group_name].__iter__()
41
 
 
42
 
    def _group_has_member(self, group_name, member):
43
 
        return group_name in self and member in self._groups[group_name]