Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions
MoinMoin.datastruct.backends.GreedyGroup Class Reference
Inheritance diagram for MoinMoin.datastruct.backends.GreedyGroup:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.datastruct.backends.GreedyGroup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __contains__
def __iter__
def __repr__

Public Attributes

 member_groups
 request
 name

Private Member Functions

def _load_group

Detailed Description

GreedyGroup gets all members during initialization and stores them internally.

Members of a group may be names of other groups.

Definition at line 167 of file __init__.py.


Constructor & Destructor Documentation

def MoinMoin.datastruct.backends.GreedyGroup.__init__ (   self,
  request,
  name,
  backend 
)
Initialize a group.

@param request
@param name: moin group name
@backend: backend object which created this object

Reimplemented from MoinMoin.datastruct.backends.BaseGroup.

Definition at line 174 of file __init__.py.

00174 
00175     def __init__(self, request, name, backend):
00176 
00177         super(GreedyGroup, self).__init__(request, name, backend)
00178         self.members, self.member_groups = self._load_group()


Member Function Documentation

def MoinMoin.datastruct.backends.GreedyGroup.__contains__ (   self,
  member,
  processed_groups = None 
)
First check if <member> is part of this group and then check
for every subgroup in this group.

<processed_groups> is needed to avoid infinite recursion, if
groups are defined recursively.

@param member: member name [unicode]
@param processed_groups: groups which were checked for containment before [set]

Reimplemented from MoinMoin.datastruct.backends.BaseGroup.

Definition at line 190 of file __init__.py.

00190 
00191     def __contains__(self, member, processed_groups=None):
00192         """
00193         First check if <member> is part of this group and then check
00194         for every subgroup in this group.
00195 
00196         <processed_groups> is needed to avoid infinite recursion, if
00197         groups are defined recursively.
00198 
00199         @param member: member name [unicode]
00200         @param processed_groups: groups which were checked for containment before [set]
00201         """
00202 
00203         if processed_groups is None:
00204             processed_groups = set()
00205 
00206         processed_groups.add(self.name)
00207 
00208         if member in self.members or member in self.member_groups:
00209             return True
00210         else:
00211             groups = self.request.groups
00212             for group_name in self.member_groups:
00213                 if group_name not in processed_groups and group_name in groups and groups[group_name].__contains__(member, processed_groups):
00214                     return True
00215 
00216         return False

def MoinMoin.datastruct.backends.GreedyGroup.__iter__ (   self,
  yielded_members = None,
  processed_groups = None 
)
Iterate first over members of this group, then over subgroups of this group.

<yielded_members> and <processed_groups> are needed to avoid infinite recursion.
This can happen if there are two groups like these:
   OneGroup: Something, OtherGroup
   OtherGroup: OneGroup, SomethingOther

@param yielded_members: members which have been already yielded before [set]
@param processed_groups: group names which have been iterated before [set]

Reimplemented from MoinMoin.datastruct.backends.BaseGroup.

Definition at line 217 of file __init__.py.

00217 
00218     def __iter__(self, yielded_members=None, processed_groups=None):
00219         """
00220         Iterate first over members of this group, then over subgroups of this group.
00221 
00222         <yielded_members> and <processed_groups> are needed to avoid infinite recursion.
00223         This can happen if there are two groups like these:
00224            OneGroup: Something, OtherGroup
00225            OtherGroup: OneGroup, SomethingOther
00226 
00227         @param yielded_members: members which have been already yielded before [set]
00228         @param processed_groups: group names which have been iterated before [set]
00229         """
00230 
00231         if processed_groups is None:
00232             processed_groups = set()
00233 
00234         if yielded_members is None:
00235             yielded_members = set()
00236 
00237         processed_groups.add(self.name)
00238 
00239         for member in self.members:
00240             if member not in yielded_members:
00241                 yielded_members.add(member)
00242                 yield member
00243 
00244         groups = self.request.groups
00245         for group_name in self.member_groups:
00246             if group_name not in processed_groups:
00247                 if group_name in groups:
00248                     for member in groups[group_name].__iter__(yielded_members, processed_groups):
00249                         yield member
00250                 else:
00251                     yield group_name

Definition at line 252 of file __init__.py.

00252 
00253     def __repr__(self):
00254         return "<%s name=%s members=%s member_groups=%s>" % (self.__class__,
00255                                                              self.name,
00256                                                              self.members,
00257                                                              self.member_groups)
00258 

Retrieve group data from the backend and filter it to members and group_members.

Reimplemented in MoinMoin.datastruct.backends.wiki_groups.WikiGroup.

Definition at line 179 of file __init__.py.

00179 
00180     def _load_group(self):
00181         """
00182         Retrieve group data from the backend and filter it to members and group_members.
00183         """
00184         members_retrieved = set(self._backend._retrieve_members(self.name))
00185 
00186         member_groups = set(member for member in members_retrieved if self._backend.is_group_name(member))
00187         members = members_retrieved - member_groups
00188 
00189         return members, member_groups


Member Data Documentation

Definition at line 177 of file __init__.py.

Definition at line 39 of file __init__.py.

Definition at line 38 of file __init__.py.


The documentation for this class was generated from the following file: