annotate MoinMoin/groups/__init__.py @ 4775:0a0387a9eb1e

Groups2009: BackendManager does not require request object in __init__
author Dmitrijs Milajevs <dimazest@gmail.com>
date Sun, 31 May 2009 21:17:49 +0200
parents c3e904a9c00b
children 3f9147c23d9c
rev   line source
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
2
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
3 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
4 MoinMoin - group definition access via various backends.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
5
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
6 TODO Group name mapping for the BackendManager.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
7
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
8 @copyright: 2009 DmitrijsMilajevs
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
9 @license: GPL, see COPYING for details
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
10 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
11
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
12
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
13 class BackendManager(object):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
14 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
15 BackendManager maps string to the Group object. String represents
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
16 group name. It provides access to groups of specific backend.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
17 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
18
4775
0a0387a9eb1e Groups2009: BackendManager does not require request object in __init__
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4773
diff changeset
19 def __init__(self, backend, mapper_to_backend=lambda x: x, mapper_from_backend=lambda x: x):
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
20 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
21 Creates backend manager object.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
22
4767
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
23 XXX Decorators can be used for group name mapping.
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
24
4773
c3e904a9c00b Groups 2009: BackendManager gets request object in __init__
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4770
diff changeset
25 @param request: request object.
c3e904a9c00b Groups 2009: BackendManager gets request object in __init__
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4770
diff changeset
26
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
27 @type backend: group backend object.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
28 @param backend: the backend which provides access to the group
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
29 definitions.
4767
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
30
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
31 @type mapper_to_backend: function which takes one string as an
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
32 argument and returns a string
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
33 @param mapper_to_backend: function which maps moin group
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
34 name to the backend group name
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
35
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
36 @type mapper_from_backend: function which takes one string as an
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
37 argument and returns a string
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
38 @param mapper_from_backend: function which maps backend group
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
39 name to the moin group name
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
40 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
41 self._backend = backend
4770
193277fe231f Groups 2009: group name mapping functions refinement.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4767
diff changeset
42 self.mapper_to_backend = mapper_to_backend
193277fe231f Groups 2009: group name mapping functions refinement.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4767
diff changeset
43 self.mapper_from_backend = mapper_from_backend
4767
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
44
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
45 def __getitem__(self, group_name):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
46 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
47 Selection of a group by its name.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
48
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
49 @type group_name: unicode string.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
50 @param group_name: name of the group which object to select.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
51 """
4767
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
52 return self._backend[self.mapper_to_backend(group_name)]
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
53
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
54 def __iter__(self):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
55 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
56 Iteration over group names.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
57 """
4767
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
58 return (self.mapper_from_backend(group_name) for group_name in self._backend)
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
59
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
60 def __contains__(self, group_name):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
61 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
62 Check if a group called group name is avaliable via this backend.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
63
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
64 @type group_name: unicode string.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
65 @param group_name: name of the group which is checked for an containment.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
66 """
4767
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
67 return self.mapper_to_backend(group_name) in self._backend
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
68
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
69 def membergroups(self, member):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
70 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
71 List all groups where member is a member of.
4765
3ffc3eb7f265 Groups2009: @rtype and @return tags were added for the BackendManager.membergroups and the GroupManager.membergroups methods.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4763
diff changeset
72 @rtype: list of unicode strings
3ffc3eb7f265 Groups2009: @rtype and @return tags were added for the BackendManager.membergroups and the GroupManager.membergroups methods.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4763
diff changeset
73 @return: list of group names in which member takes part in
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
74 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
75 return [group_name for group_name in self
4767
3b34bbd60dca Groups2009: Group name mapping from moin to backend and vice versa
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4765
diff changeset
76 if member in self[group_name]]
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
77
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
78
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
79 class GroupManager(object):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
80 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
81 GroupManager manages several group backends.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
82 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
83
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
84 def __init__(self, backends):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
85 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
86 Create a group manager object.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
87
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
88 @type backends: list of objects.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
89 @param backend: group backends which are used to get access to the
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
90 group definitions.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
91 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
92 self._backends = backends
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
93
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
94 def __getitem__(self, group_name):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
95 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
96 Selection of a group by its name.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
97 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
98 for backend in self._backends:
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
99 if group_name in backend:
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
100 return backend[group_name]
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
101 raise KeyError("There is no such group")
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
102
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
103 def __iter__(self):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
104 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
105 Iteration over groups names.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
106 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
107 yielded_groups = set()
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
108
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
109 for backend in self._backends:
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
110 for group_name in backend:
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
111 if group_name not in yielded_groups:
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
112 yield group_name
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
113 yielded_groups.add(group_name)
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
114
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
115 def __contains__(self, group_name):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
116 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
117 Check if a group called group_name is defined.
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
118 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
119 for backend in self._backends:
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
120 if group_name in backend:
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
121 return True
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
122
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
123 def membergroups(self, member):
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
124 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
125 List all groups where member is a member of.
4765
3ffc3eb7f265 Groups2009: @rtype and @return tags were added for the BackendManager.membergroups and the GroupManager.membergroups methods.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4763
diff changeset
126 @rtype: list of unicode strings
3ffc3eb7f265 Groups2009: @rtype and @return tags were added for the BackendManager.membergroups and the GroupManager.membergroups methods.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4763
diff changeset
127 @return: list of group names in which member takes part in
4763
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
128 """
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
129 return [group_name for group_name in self
13a75c5f65c7 Groups2009: MoinMoin.groups module initial layout and tests. BackendManager and GroupManager classes were introduced.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
diff changeset
130 if member in self[group_name]]