示例#1
0
 def require_user(self, userid):
     # Initialize user, return 404 if it doesn't exist in db
     unescaped_userid = urllib.unquote_plus(userid)
     user = User(unescaped_userid)
     if not user.exists_in_db():
         abort(404)
     return user
示例#2
0
 def require_user(self, userid):
     # Initialize user, return 404 if it doesn't exist in db
     unescaped_userid = urllib.unquote_plus(userid)
     user = User(unescaped_userid)
     if not user.exists_in_db():
         abort(404)
     return user
示例#3
0
 def post(self):
     logger.logger.debug("POSTING")
     args = self.parse_args()
     user = User(args)
     try:
         if user.insert():
             return "{0} inserted".format(user.userid)
     except PrimaryKeyException as e:
         abort(403)
     except:
         abort(400)
示例#4
0
 def post(self):
     logger.logger.debug("POSTING")
     args = self.parse_args()
     user = User(args)
     try:
         if user.insert():
             return "{0} inserted".format(user.userid)
     except PrimaryKeyException as e:
         abort(403)
     except:
         abort(400)
示例#5
0
 def put(self, group_name=None):
     # TODO: create generic parser
     users = request.json
     if users is None:
         abort(400)
     group = self.require_group(group_name)
     filtered_users = [
         userid for userid in users if User(userid).exists_in_db()
     ]
     group.update(filtered_users)
     return "{0} updated".format(group_name)