コード例 #1
0
    def post(self, url):
        if not self.user:
            self.redirect('/login')
        else:
            base_url = root_url(self.url)
            content = self.request.get('content') or ''

            if self.v:
                Page.update_content(content, base_url, v=self.v)
                self.redirect(base_url + '?v={}'.format(self.v))
            else:
                Page.update_content(content, base_url)
                self.redirect(base_url)
コード例 #2
0
 def initialize(self, *args, **kwargs):
     RequestHandler.initialize(self, *args, **kwargs)
     uid = self.read_secure_cookie('user_id')
     self.user = uid and User.by_id(int(uid))
     self.url = self.request.route_args[0] if len(self.request.route_args) > 0 else '/'
     v = self.request.get('v')
     if v and v.isdigit():
         self.v = int(v)
         p = Page.by_id(int(self.v), self.url)
         if p:
             self.page = p
         else:
             self.error(404)
     else:
         self.page = Page.by_url(self.url)
 def get(self, url):
     pages = Page.all_by_path(url)
     if pages:
         self.render_page(url, user=self.user, pages=pages)
     elif not pages and self.user:
         self.redirect('/_edit' + url)
     else:
         self.redirect('/login')
 def get(self, url):
     pages = Page.all_by_path(url)
     if pages:
         self.render_page(url, user=self.user, pages=pages)
     elif not pages and self.user:
         self.redirect('/_edit' + url)
     else:
         self.redirect('/login')