Back to index

moin  1.9.0~rc2
config_lazy_groups.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - config group lazy backend.
00004 
00005     The config group backend allows one to define groups in a
00006     configuration file.
00007 
00008     NOTE that this is proof-of-concept implementation. LDAP backend
00009     should be based on this concept.
00010 
00011     @copyright: 2009 MoinMoin:DmitrijsMilajevs
00012     @license: GPL, see COPYING for details
00013 """
00014 
00015 from MoinMoin.datastruct.backends import LazyGroup, LazyGroupsBackend
00016 
00017 
00018 class ConfigLazyGroup(LazyGroup):
00019     pass
00020 
00021 
00022 class ConfigLazyGroups(LazyGroupsBackend):
00023 
00024     def __init__(self, request, groups):
00025         super(ConfigLazyGroups, self).__init__(request)
00026 
00027         self._groups = groups
00028 
00029     def __contains__(self, group_name):
00030         return group_name in self._groups
00031 
00032     def __iter__(self):
00033         return self._groups.iterkeys()
00034 
00035     def __getitem__(self, group_name):
00036         return ConfigLazyGroup(self.request, group_name, self)
00037 
00038     def _iter_group_members(self, group_name):
00039         if group_name in self:
00040             return self._groups[group_name].__iter__()
00041 
00042     def _group_has_member(self, group_name, member):
00043         return group_name in self and member in self._groups[group_name]