SHARE
TWEET

Untitled

a guest Aug 1st, 2016 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Post(db.Model):
  2.     subject = db.StringProperty(required=True) #particular type
  3.     content = db.TextProperty(required=True)
  4.     created = db.DateTimeProperty(auto_now_add=True)
  5.     last_modified = db.DateTimeProperty(auto_now=True)
  6.  
  7.     def render(self):
  8.         print ("[!] render in Post")
  9.         self._render_text = self.content.replace('\n', '<br>')
  10.         return render_str("post.html", p = self)
  11.  
  12. class NewPost(Handler):
  13.     def get(self):
  14.         #render form page
  15.         self.render("newpost.html")
  16.  
  17.     def post(self):
  18.         subject = self.request.get("subject")
  19.         content = self.request.get("content")
  20.  
  21.         if subject and content:
  22.             p = Post(subject=subject, content=content)
  23.             #add to the DB
  24.             p.put()
  25.  
  26.             self.redirect('/blog/%s' % str(p.key().id()))
  27.         else:
  28.             print ("[!] Error")
  29.             print (subject)
  30.             print(content)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top