~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/userservice/__init__.py

  • Committer: William Grant
  • Date: 2009-01-20 03:14:49 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: grantw@unimelb.edu.au-20090120031449-8l360qtifu2aulux
wwww/apps/userservice: Create group memberships using Storm, not ivle.db.
    That is the last reference to ivle.db gone. Remove the dependency on
    that and ivle.makeuser, which has been unused for a while.

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
import cjson
145
145
import pg
146
146
 
147
 
import ivle.db
148
147
import ivle.database
149
 
import ivle.makeuser
150
148
from ivle import (util, chat, caps)
151
149
from ivle.conf import (usrmgt_host, usrmgt_port, usrmgt_magic)
152
150
import ivle.pulldown_subj
682
680
    if login is None or groupid is None:
683
681
        req.throw_error(req.HTTP_BAD_REQUEST,
684
682
            "Required: login, groupid")
685
 
    groupid = int(groupid)
686
 
 
687
 
    loginid = ivle.database.User.get_by_login(req.store, login).id
688
 
 
689
 
    # Talk to the DB
690
 
    db = ivle.db.DB()
691
 
 
692
 
    # Add assignment to database
693
 
    # We can't use a transaction here, as usrmgt-server needs to see the
694
 
    # changes!
 
683
 
 
684
    group = req.store.get(ivle.database.ProjectGroup, int(groupid))
 
685
    user = ivle.database.User.get_by_login(req.store, login)
 
686
 
 
687
    # Add membership to database
 
688
    # We can't keep a transaction open until the end here, as usrmgt-server
 
689
    # needs to see the changes!
695
690
    try:
696
 
        dbquery = db.insert(
697
 
            {
698
 
                'loginid': loginid,
699
 
                'groupid': groupid,
700
 
            },
701
 
            "group_member", # table
702
 
            frozenset(["loginid", "groupid"]), # fields
703
 
        )
 
691
        group.members.add(user)
 
692
        req.store.commit()
704
693
 
705
694
        # Rebuild the svn config file
706
695
        # Contact the usrmgt server
716
705
                    "Failure creating repository: %s"%str(usrmgt))
717
706
    except Exception, e:
718
707
        req.throw_error(req.HTTP_INTERNAL_SERVER_ERROR, repr(e))
719
 
    finally:
720
 
        db.close()
721
708
 
722
709
    return(cjson.encode({'response': 'okay'}))
723
710