Back to index

moin  1.9.0~rc2
Functions
MoinMoin.auth.openidrp_ext.openidrp_teams Namespace Reference

Functions

def openidrp_teams_modify_request
def openidrp_teams_create_user
def openidrp_teams_update_user
def _save_teams_acl
def _add_user_to_team
def _remove_user_from_team

Function Documentation

def MoinMoin.auth.openidrp_ext.openidrp_teams._add_user_to_team (   u,
  team,
  cfg 
) [private]

Definition at line 81 of file openidrp_teams.py.

00081 
00082 def _add_user_to_team(u, team, cfg):
00083     # use admin account to create or edit ACL page
00084     # http://moinmo.in/MoinDev/CommonTasks
00085     acl_request = u._request
00086     acl_request.user = user.User(acl_request, None, cfg.openidrp_acl_admin)
00087     pe = PageEditor(acl_request, team + cfg.openidrp_acl_page_postfix)
00088     acl_text = pe.get_raw_body()
00089     logging.log(logging.INFO, "ACL Page content: " + acl_text)
00090     # make sure acl command is first line of document
00091     # only the admin user specified in wikiconfig should
00092     # be allowed to change these acl files
00093     if not acl_text or acl_text == "" or acl_text[0] != "#":
00094         acl_text = "#acl Known:read All:\n" + acl_text
00095     # does ACL want uid, name, username, auth_username?
00096     p = re.compile(ur"^ \* %s" % u.name, re.MULTILINE)
00097     if not p.search(acl_text):
00098         logging.log(logging.INFO, "did not find user %s in acl, adding..." % u.name)
00099         acl_text += u" * %s\n" % u.name
00100         pe.saveText(acl_text, 0)

Here is the caller graph for this function:

def MoinMoin.auth.openidrp_ext.openidrp_teams._remove_user_from_team (   u,
  team,
  cfg 
) [private]

Definition at line 101 of file openidrp_teams.py.

00101 
00102 def _remove_user_from_team(u, team, cfg):
00103     acl_request = u._request
00104     acl_request.user = user.User(acl_request, None, cfg.openidrp_acl_admin)
00105     pe = PageEditor(acl_request, team + cfg.openidrp_acl_page_postfix)
00106     acl_text = pe.get_raw_body()
00107     logging.log(logging.INFO, "ACL Page content: " + acl_text)
00108     # does ACL want uid, name, username, auth_username?
00109     p = re.compile(ur"^ \* %s" % u.name, re.MULTILINE)
00110     if p.search(acl_text):
00111         logging.log(logging.INFO, "found user %s in acl, removing..." % u.name)
00112         acl_text = acl_text.replace(" * %s\n" % u.name, "")
00113         try:
00114             pe.saveText(acl_text, 0)
00115         except PageEditor.EmptyPage:
00116             pe.deletePage()
00117 

Here is the caller graph for this function:

def MoinMoin.auth.openidrp_ext.openidrp_teams._save_teams_acl (   u,
  teams,
  cfg 
) [private]

Definition at line 56 of file openidrp_teams.py.

00056 
00057 def _save_teams_acl(u, teams, cfg):
00058     logging.log(logging.INFO, "running save_teams_acl...")
00059 
00060     # remove any teams the user is no longer in
00061     if not hasattr(u, 'teams'):
00062         u.teams = []
00063     logging.log(logging.INFO, "old teams: " + str(u.teams)
00064         + "  new teams: " + str(teams))
00065 
00066     for t in u.teams:
00067         if not t in teams:
00068             logging.log(logging.INFO, "remove user from team: " + t)
00069             team = t.strip().replace("-", "")
00070             _remove_user_from_team(u, team, cfg)
00071 
00072     for t in teams:
00073         team = t.strip().replace("-", "")
00074         if not team:
00075             continue
00076         logging.log(logging.INFO, "Launchpad team: "  + team)
00077         _add_user_to_team(u, team, cfg)
00078 
00079     u.teams = teams
00080     u.save()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 37 of file openidrp_teams.py.

00037 
00038 def openidrp_teams_create_user(info, u, cfg):
00039     # Check for Launchpad teams data in response
00040     teams = None
00041     #if teams_extension_avail and len(cfg.openidrp_authorized_teams) > 0:
00042     teams_response = TeamsResponse.fromSuccessResponse(info)
00043     teams = teams_response.is_member
00044     if teams:
00045         _save_teams_acl(u, teams, cfg)
00046     return u

Here is the call graph for this function:

Definition at line 30 of file openidrp_teams.py.

00030 
00031 def openidrp_teams_modify_request(oidreq, cfg):
00032     # Request Launchpad teams information, if configured
00033     # should also check supportsTeams() result
00034     #if teams_extension_avail and len(cfg.openidrp_authorized_teams) > 0:
00035     if len(cfg.openidrp_authorized_teams) > 0:
00036         oidreq.addExtension(TeamsRequest(cfg.openidrp_authorized_teams))

Definition at line 47 of file openidrp_teams.py.

00047 
00048 def openidrp_teams_update_user(info, u, cfg):
00049     teams = None
00050     teams_response = TeamsResponse.fromSuccessResponse(info)
00051     teams = teams_response.is_member
00052     if teams:
00053         _save_teams_acl(u, teams, cfg)
00054 
00055 # Take a list of Launchpad teams and add the user to the ACL pages
# ACL group names cannot have "-" in them, although team names do.

Here is the call graph for this function: