class PhpbbGroupsBackend(LazyGroupsBackend):
class PhpbbGroup(LazyGroup):
+ """
+ A group from phpbb.
+ """
pass
-
def __init__(self, request, auth):
super(LazyGroupsBackend, self).__init__(request)
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` \
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 \
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 \
(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 \
return conn
def login(self, request, user_obj, **kw):
+ """
+ Handle a login. Called by moinmoin.
+ """
try:
username = kw.get('username')
password = kw.get('password')