def create(self, name, exten, dnis, comment, app_begin=None, app_end=None, active=True, owner_id=None, **kw): """ Add new application and initial dialplan to DB """ a = Application() a.name = name a.exten = exten a.dnis = dnis a.active = active a.begin = app_begin a.end = app_end a.comment = comment a.created_by = request.identity["user"].user_id if owner_id: a.owner_id = owner_id else: a.owner_id = request.identity["user"].user_id # Try to insert file in DB: might fail if name already exists try: DBSession.add(a) DBSession.flush() except: log.error(u"Insert failed %s" % a) flash(u"Impossible de créer l'application (vérifier son nom)", "error") redirect("/applications/") s = Scenario() s.app_id = a.app_id s.context = "Entrant" s.extension = "s" s.step = 1 s.action = 0 s.parameters = None DBSession.add(s) flash(u'Nouvelle application "%s" créée' % (name)) redirect("/applications/")