def response(self): if self.request.method == 'POST': max_id = max([art['id'] for art in ARTICLES]) ARTICLES.append( {'id': max_id+1, 'title': self.request.POST['title'], 'content': self.request.POST['content'] } ) return Response(status=302, location='/') return Response(env.get_template('create.html').render(article=None))
def __iter__(self): if self.environ['REQUEST_METHOD'].upper() == 'POST': from urlparse import parse_qs values = parse_qs(self.environ['wsgi.input'].read()) max_id = max([art['id'] for art in ARTICLES]) ARTICLES.append({ 'id': max_id + 1, 'title': values['title'].pop().decode('utf-8'), 'content': values['content'].pop().decode('utf-8') }) self.start('302 Found', [('Content-Type', 'text/html'), ('Location', '/')]) return self.start('200 OK', [('Content-Type', 'text/html')]) yield env.get_template('create.html').render(article=None)
def __iter__(self): if self.environ['REQUEST_METHOD'].upper() == 'POST': from urlparse import parse_qs values = parse_qs(self.environ['wsgi.input'].read()) max_id = max([art['id'] for art in ARTICLES]) ARTICLES.append({ 'id': max_id + 1, 'title': values['title'].pop(), 'content': values['content'].pop() }) self.start('302 Found', [('Content-Type', 'text/html'), ('Location', '/')]) return self.start('200 OK', [('Content-Type', 'text/html')]) yield '<h1><a href="/">Simple Blog</a> -> CREATE</h1>' yield '''
def __iter__(self): if self.environ['REQUEST_METHOD'].upper() == 'POST': from urlparse import parse_qs values = parse_qs(self.environ['wsgi.input'].read()) max_id = max([art['id'] for art in ARTICLES]) ARTICLES.append( {'id': max_id+1, 'title': values['title'].pop().decode('utf-8'), 'content': values['content'].pop().decode('utf-8') } ) self.start('302 Found', [('Content-Type', 'text/html'), ('Location', '/')]) return self.start('200 OK', [('Content-Type', 'text/html')]) yield env.get_template('create.html').render(article=None)
def __iter__(self): if self.environ["REQUEST_METHOD"].upper() == "POST": from urlparse import parse_qs values = parse_qs(self.environ["wsgi.input"].read()) max_id = max([art["id"] for art in ARTICLES]) ARTICLES.append( { "id": max_id + 1, "title": values["title"].pop().decode("utf-8"), "content": values["content"].pop().decode("utf-8"), } ) self.start("302 Found", [("Content-Type", "text/html"), ("Location", "/")]) return self.start("200 OK", [("Content-Type", "text/html")]) yield env.get_template("create.html").render(article=None)
def __iter__(self): if self.environ['REQUEST_METHOD'].upper() == 'POST': from urlparse import parse_qs values = parse_qs(self.environ['wsgi.input'].read()) max_id = max([art['id'] for art in ARTICLES]) ARTICLES.append( {'id': max_id+1, 'title': values['title'].pop(), 'content': values['content'].pop() } ) self.start('302 Found', [('Content-Type', 'text/html'), ('Location', '/')]) return self.start('200 OK', [('Content-Type', 'text/html')]) yield '<h1><a href="/">Simple Blog</a> -> CREATE</h1>' yield '''
def response(self): if self.request.method == 'POST': submitted = self.request.POST.items() try: self.get_form().validate(submitted) except deform.ValidationFailure as e: return Response( env.get_template('create.html').render(form=e.render())) max_id = max([art['id'] for art in ARTICLES]) ARTICLES.append( {'id': max_id+1, 'title': self.request.POST['title'], 'content': self.request.POST['content'] } ) self.session = get_session(self.request).pop('csrf') return Response(status=302, location='/') return Response(env.get_template('create.html') .render(form=self.get_form().render()))
def __iter__(self): self.start( '302 Found', # '301 Moved Permanently', [('Content-Type', 'text/html'), ('Location', '/')]) ARTICLES.pop(self.index) yield ''
def __iter__(self): self.start('302 Found', # '301 Moved Permanently', [('Content-Type', 'text/html'), ('Location', '/')]) ARTICLES.pop(self.index) yield ''
def __iter__(self): self.start("302 Found", [("Content-Type", "text/html"), ("Location", "/")]) # '301 Moved Permanently', ARTICLES.pop(self.index) yield ""
def response(self): ARTICLES.pop(self.index) return Response(status=302, location='/')
def response(self): from webob import Response ARTICLES.pop(self.index) return Response(status=302, location='/')