Пример #1
0
 def setUp(self):
     """Setup test fixture for each model test method."""
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
Пример #2
0
 def save_contact(self, **kw):
     c = model.Contact()
     c.display_name = kw['name']
     c.phone_number = kw['number']
     DBSession.add(c)
     logged = DBSession.query(
         model.User).filter(model.User.user_name ==
                            request.identity['repoze.who.userid']).first()
     logged.address_book.append(c)
     DBSession.add(logged)
     DBSession.flush()
     transaction.commit()
     redirect('/contacts')
     flash(_('Contact %s added!') % kw['name'])