def save(self): with lock.gen_wlock(): if self.id == None: self.id = str(uuid4()) messages[self.id] = self setKey(f"/messages/{self.id}/message.json", self.toJSONSimple()) for callback in Message.saveCallbacks: callback(self)
def save(self): with lock.gen_wlock(): if self.id == None: self.id = str(uuid4()) contests[self.id] = self setKey(f"/contests/{self.id}/contest.json", self.toJSONSimple()) for callback in Contest.saveCallbacks: callback(self)
def save(self, addUser = True): # Don't create another user with a duplicate username if self.username in [user.username for user in User.all()]: return # Add the user to the database if desired if addUser: users[self.id] = self userNames[self.username] = self usrs = [users[id].toJSON() for id in users] setKey("/users.json", usrs)
def save(self): with lock.gen_wlock(): if self.id == None: c = Contest.getCurrent() probNum = 0 if c: for i, prob in enumerate(c.problems): if prob == self.problem: probNum = i + 1 timestr = time.strftime("%H%M%S", time.localtime(self.timestamp / 1000)) self.id = f"{self.user.username}-{probNum}-{timestr}" submissions[self.id] = self self.version += 1 setKey(f"/submissions/{self.id}/submission.json", self.toJSONSimple()) for callback in Submission.saveCallbacks: callback(self)
def save(self): with lock.gen_wlock(): if self.id == None: self.id = str(uuid4()) problems[self.id] = self setKey(f"/problems/{self.id}/problem.json", self.toJSONSimple()) for i, datum in enumerate(self.testData): setKey(f"/problems/{self.id}/input/in{i}.txt", datum.input) setKey(f"/problems/{self.id}/output/out{i}.txt", datum.output) self.sampleData = [ Datum.get(self.id, i) for i in range(self.samples) ] for callback in Problem.saveCallbacks: callback(self)