From 779219209f121b987481952bc1f47940c70943ca Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 2 Jul 2010 14:05:35 +0200 Subject: [PATCH] phpbb: Add docstrings to a few methods. --- conf/auth/phpbb.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/conf/auth/phpbb.py b/conf/auth/phpbb.py index 3c1f806..5185eb3 100644 --- a/conf/auth/phpbb.py +++ b/conf/auth/phpbb.py @@ -17,9 +17,11 @@ logging = log.getLogger(__name__) class PhpbbGroupsBackend(LazyGroupsBackend): class PhpbbGroup(LazyGroup): + """ + A group from phpbb. + """ pass - def __init__(self, request, auth): super(LazyGroupsBackend, self).__init__(request) @@ -27,12 +29,18 @@ class PhpbbGroupsBackend(LazyGroupsBackend): self.request = request def __iter__(self): + """ + Return a list of group names. + """ return self.list_query("SELECT group_name \ FROM `%sgroups` \ WHERE group_single_user = 0" % self.auth.phpbb_prefix) def __contains__(self, group_name): + """ + Does a group with the given name exist? + """ return self.single_query("SELECT EXISTS ( \ SELECT * \ FROM `%sgroups` \ @@ -41,9 +49,16 @@ class PhpbbGroupsBackend(LazyGroupsBackend): group_name) def __getitem__(self, group_name): + """ + Get the group with the given name. + """ return self.PhpbbGroup(self.request, group_name, self) def _iter_group_members(self, group_name): + """ + Get all member names for the given group. This is called by + LazyGroup.__iter__. + """ return self.list_query ("SELECT username \ FROM `%susers` as u, `%suser_group` as ug, `%sgroups` as g \ WHERE u.user_id = ug.user_id AND ug.group_id = g.group_id \ @@ -53,6 +68,10 @@ class PhpbbGroupsBackend(LazyGroupsBackend): group_name) def _group_has_member(self, group_name, member): + """ + Does the group with the given name have a member with the given name? + This is called by LazyGroup.__contains__. + """ return self.single_query ("SELECT EXISTS( \ SELECT * \ FROM `%susers` as u, `%suser_group` as ug, `%sgroups` as g \ @@ -63,6 +82,10 @@ class PhpbbGroupsBackend(LazyGroupsBackend): (group_name, member)) def groups_with_member(self, member): + """ + Return the group names for all groups that have a member with the + given name. + """ return self.list_query ("SELECT g.group_name \ FROM `%susers` as u, `%suser_group` as ug, `%sgroups` as g \ WHERE u.user_id = ug.user_id AND ug.group_id = g.group_id \ @@ -201,6 +224,9 @@ class PhpbbAuth(BaseAuth): return conn def login(self, request, user_obj, **kw): + """ + Handle a login. Called by moinmoin. + """ try: username = kw.get('username') password = kw.get('password') -- 2.30.2