def create(self, **kw): """Create a new arch and save it to the database.""" user = request.environ.get('repoze.who.identity')['user'] name = kw['name'] comment = kw['comment'] owner = User.by_user_name(kw['owner']) if comment == "": comment = name arch = Arch() arch.name = name arch.state.creator = user arch.state.owner = owner arch.comments.append(Comment(comment=comment)) DBSession.add(arch) DBSession.flush() redirect("index")