Ejemplo n.º 1
0
 def post(self):
     last = Entry.all().order('-created').get()
     entry = Entry()
     if last:
         entry.id = last.id + 1
     else:
         entry.id = 1
     entry.created = int(time.time())
     entry.title = self.get_argument('title', default='', strip=True)
     entry.tags = [item for item in self.get_argument('tags', default='', strip=True).split(',')]
     entry.content = markdown.markdown(self.get_argument('content', default='', strip=True))
     entry.hits = 0
     entry.lastmodify = int(time.time())
     entry.put()
     self.redirect('/writer/')
Ejemplo n.º 2
0
    def post(self):
        error = {'status':'Access Denied.'}
        author = Author.all().get()
        if not self.get_arguments('key') or not author:
            self.write(simplejson.dumps(error))
            return
        if self.get_argument('key') != author.sync_key:
            self.write(simplejson.dumps(error))
            return

        entry = Entry()
        entry.id = int(self.get_argument('id'))
        entry.created = int(self.get_argument('created'))
        entry.title = self.get_argument('title')
        entry.tags = [item for item in self.get_argument('tags').split(',')]
        entry.content = self.get_argument('content')
        entry.hits = 0
        entry.lastmodify = int(self.get_argument('lastmodify'))
        entry.put()
        response = {'status':'ok'}
        self.write(simplejson.dumps(response))