Пример #1
0
 def commit_to_session(self, session=session):
     """Commit this problem to the database as a new problem."""
     session.add(self)
     session.flush()
     session.commit()
     session.refresh(self)
     return self.pid
Пример #2
0
 def commit_to_session(self, session=session):
     """Commit this blog post to the database"""
     session.add(self)
     session.flush()
     session.commit()
     session.refresh(self)
     return self.id
Пример #3
0
    def commit_to_session(self):
        """Commit this CompUser to the database.

        This is useful for adding a newly-created CompUser to the database.
        """
        session.add(self)
        session.flush()
        session.commit()
        session.refresh(self)
        self._problem = None
Пример #4
0
    def commit_to_session(self, session=session):
        """Commit this Competition to the database.

        This is useful for adding a newly-created Competition to the database.
        """
        session.add(self)
        session.flush()
        session.commit()
        session.refresh(self)
        self._problem = None
        return self.cid
Пример #5
0
    def commit_to_session(self):
        '''Commit this Submission to the database.

        This is useful for adding a newly-created Submission to the database.
        '''
        dblock.acquire()
        session.add(self)
        session.flush()
        session.commit()
        session.refresh(self)
        dblock.release()
        self._problem = None
Пример #6
0
def create_blog_post():
    if not current_user.admin == 1:
        return serve_error('You must be an admin to submit blog posts', response_code=401)
    if not request.form['title'] or not request.form['subtitle'] or not request.form['body']:
        return serve_error('Must include title, subtitle, and body with request', 
                           response_code=400)
    post = BlogPost(title=request.form['title'],
                    subtitle=request.form['subtitle'],
                    post_time=int(time()),
                    body=request.form['body'],
                    username=current_user.username)
    session.add(post)
    session.flush()
    session.commit()
    session.refresh(post)
    return serve_response(create_blog_object(post))
Пример #7
0
    def insert_into_db(session, model, args_list):
        """
        Insert a number of ORM objects into the session for testing. The number
        of objects inserted is equal to the length of the args_list parameter.

        :param session: the database session to insert into
        :param model: the model class of the objects to be added
        :param args: a list of the arguments to pass to the model constructor
        :param num: the number of ORM objects to create and insert
        :returns: the list of new ORM objects
        """
        results = list()
        for args in args_list:
            model_object = model(**args)
            session.add(model_object)
            session.flush()
            session.commit(self)
            session.refresh(model_object)
            results.append(model_object)

        return results
Пример #8
0
 def commit_to_session(self):
     """Commit this problem to the database as a new template."""
     session.add(self)
     session.flush()
     session.commit()
     session.refresh(self)
Пример #9
0
 def commit_to_session(self):
     """Commit this problem to the database as a new template."""
     session.add(self)
     session.flush()
     session.commit()
     session.refresh(self)
Пример #10
0
 def commit_to_session(self, session=session):
     """Commit this sample case to the database."""
     session.add(self)
     session.flush()
     session.commit()
     session.refresh(self)
Пример #11
0
 def commit_to_session(self, session=session):
     """Commit this problem data object to the database."""
     session.add(self)
     session.flush()
     session.commit()
     session.refresh(self)
Пример #12
0
 def commit_to_session(self):
     session.add(self)
     session.flush()
     session.commit()
     session.refresh(self)