def gets(self, paragraph_id):
     method_name = 'SentenceMapper.gets'
     log.info('{}: initialization.'.format(method_name))
     sentences = []
     for db_sentence in Sentences.select().where(Sentences.paragraph_id==paragraph_id):
         sentences.append(self.mapper(db_sentence));
     log.info('{}: end.'.format(method_name))
     return sentences
 def update(self, sentence_object):
     method_name = 'SentenceMapper.update'
     log.info('{}: initialization.'.format(method_name))
     query = Sentences.update(paragraph_id=sentence_object.paragraph_id, 
                          number_of_words=sentence_object.number_of_words, 
                          order_in_paragraph=sentence_object.order_in_paragraph).where(Sentences.id==sentence_object.id)
     log.info('{}: end.'.format(method_name))
     if query.execute() != 1: return True
     else: return False
 def insert(self, sentence_object):
     method_name = 'SentenceMapper.insert'
     log.info('{}: initialization.'.format(method_name))
     query = Sentences.insert(paragraph_id=sentence_object.paragraph_id, 
                          number_of_words=sentence_object.number_of_words, 
                          order_in_paragraph=sentence_object.order_in_paragraph)
     sentence_object.id = query.execute() # Return new id
     log.info('{}: end.'.format(method_name))
     return sentence_object
예제 #4
0
 def gets(self, paragraph_id):
     method_name = 'SentenceMapper.gets'
     log.info('{}: initialization.'.format(method_name))
     sentences = []
     for db_sentence in Sentences.select().where(
             Sentences.paragraph_id == paragraph_id):
         sentences.append(self.mapper(db_sentence))
     log.info('{}: end.'.format(method_name))
     return sentences
예제 #5
0
 def insert(self, sentence_object):
     method_name = 'SentenceMapper.insert'
     log.info('{}: initialization.'.format(method_name))
     query = Sentences.insert(
         paragraph_id=sentence_object.paragraph_id,
         number_of_words=sentence_object.number_of_words,
         order_in_paragraph=sentence_object.order_in_paragraph)
     sentence_object.id = query.execute()  # Return new id
     log.info('{}: end.'.format(method_name))
     return sentence_object
예제 #6
0
 def update(self, sentence_object):
     method_name = 'SentenceMapper.update'
     log.info('{}: initialization.'.format(method_name))
     query = Sentences.update(
         paragraph_id=sentence_object.paragraph_id,
         number_of_words=sentence_object.number_of_words,
         order_in_paragraph=sentence_object.order_in_paragraph).where(
             Sentences.id == sentence_object.id)
     log.info('{}: end.'.format(method_name))
     if query.execute() != 1: return True
     else: return False
 def get(self, sentence_id):
     method_name = 'SentenceMapper.get'
     log.info('{}: initialization.'.format(method_name))
     
     try:
         sentence_object = Sentences.get(Sentences.id==sentence_id)
         log.info('{}: end.'.format(method_name))
         return self.mapper(sentence_object)
     except Exception as e:
         log.info('SentenceDoesNotExist errno={}: strerror{}.'.format(e.errno, e.strerror))
         log.info('{}: end.'.format(method_name))
         raise Exception('SentenceDoesNotExist errno={}: strerror{}.'.format(e.errno, e.strerror))
예제 #8
0
    def get(self, sentence_id):
        method_name = 'SentenceMapper.get'
        log.info('{}: initialization.'.format(method_name))

        try:
            sentence_object = Sentences.get(Sentences.id == sentence_id)
            log.info('{}: end.'.format(method_name))
            return self.mapper(sentence_object)
        except Exception as e:
            log.info('SentenceDoesNotExist errno={}: strerror{}.'.format(
                e.errno, e.strerror))
            log.info('{}: end.'.format(method_name))
            raise Exception(
                'SentenceDoesNotExist errno={}: strerror{}.'.format(
                    e.errno, e.strerror))