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

« back to all changes in this revision

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

  • Committer: mattgiuca
  • Date: 2008-03-15 04:20:30 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:693
db: get_problem_problemid now automatically inserts a new entry if the problem
    doesn't exist (now it is no longer referentially transparent, but it is
    idempotent).
    Removed insert_problem - you can just call get_problem_problemid to do
    this.
tutorialservice: No longer tries to insert a new entry if problem doesnt
    exist, just expects db to do this.
    No longer calls insert_problem (removed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
 
98
98
    conn = db.DB()
99
99
 
100
 
    try:
101
 
        problemid = conn.get_problem_problemid(exercise)
102
 
    except Exception, e:
103
 
        # if we failed to get a problemid, it was probably because
104
 
        # the exercise wasn't in the db. So lets insert it!
105
 
        #
106
 
        # The insert can fail if someone else simultaneously does
107
 
        # the insert, so if the insert fails, we ignore the problem. 
108
 
        try:
109
 
            conn.insert_problem(exercise)
110
 
        except Exception, e:
111
 
            pass
112
 
 
113
 
        # Assuming the insert succeeded, we should be able to get the
114
 
        # problemid now.
115
 
        problemid = conn.get_problem_problemid(exercise)
116
 
 
 
100
    problemid = conn.get_problem_problemid(exercise)
117
101
    loginid = conn.get_user_loginid(req.user.login)
118
102
 
119
103
    conn.insert_problem_attempt(