Exemple #1
0
 def update(self, text):
     with transaction.manager:
         try:
             d = self.session.query(Description).filter_by(text=text).one()
         except NoResultFound:
             d = Description()
             d.text = text
             self.session.add(d)
             d = self.session.merge(d)
     return d
Exemple #2
0
 def new(self, text):
     with transaction.manager:
         d = Description()
         d.text = text
         self.session.add(d)
     return self.session.merge(d)