Exemple #1
0
  def get(self, name):
    """Handles the get requests for edit page of the wiki pages

    The user will get redirected to the SignupPage if authentication fails.

    If a version is specified in the url it retreives the corresponding version
    of the requested page. If the version doesn't exists, it redirects to the
    requested edit page without a version specified.

    If no version is specified the latest version of the page will be retreived
    to be displayed.

    If there is no version of the page in the datastore, the requested name will
    be transformed and used for Page.name.
    """
    self.restrictedArea()
    name = utils.checkPage(name)

    version = self.request.get('v')
    version = 0 if not version else int(version) 
    
    page = Page.getName(name, version)

    if not page and version:
      self.redirect('/_edit/%s' % name)
      return None

    if not page and not version:
      page = Page.createPage(name)

    params = { 'page': page }
    self.render(settings.TEMPLATE_FILENAME['edit'], **params)
Exemple #2
0
  def get(self, name):
    """Handles the get requests for the wiki pages

    If a version is specified in the url it retreives the corresponding version
    of the requested page. If the version doesn't exists, it redirects to the
    requested page without a version specified.

    If no version is specified the latest version of the page will be retreived
    to be displayed.

    If there is no version of the page in the datastore, the user will be 
    redirected to '/_edit' which will be handled by EditPage.
    """
    name = utils.checkPage(name)
    version = self.checkVersionRequest()
    
    page = Page.getName(name, version)
    last_pages = Page.getLast(10)

    if page:
      params = { 'page':  page, 'last_pages': last_pages }
      self.render(settings.TEMPLATE_FILENAME['wiki'], **params)
    else:
      if version:
        self.redirect('/%s' % name)
      else:
        self.redirect('/_edit/%s' % name)
Exemple #3
0
    def get(self, name):
        name = utils.checkPage(name)

        pages = Page.getNameAll(name)
        result = []

        for page in pages:
            result.append(page.to_dict(exclude=["name"]))

        if result:
            self.renderJson(result)
        else:
            self.abort(404)
Exemple #4
0
  def get(self, name):
    """Handles the get requests for the history pages

    If the requested page doesn't exist, the user will be redirected to the root
    url.
    """
    name = utils.checkPage(name)
    versions = Page.getNameAll(name)
    
    if not versions:
      self.redirect('/')
      return None
    
    params = { 'versions': versions, 'page': versions[0] }
    self.render(settings.TEMPLATE_FILENAME['history'], **params)
Exemple #5
0
    def get(self, name):
        """Handles the get requests for the page API

    If a version is specified in the url it retreives the corresponding version
    of the requested page.

    If the requested version or page doesn't exist, a 404 will be served.    
    """
        name = utils.checkPage(name)
        version = self.checkVersionRequest()

        page = Page.getName(name, version)

        if page:
            self.renderJson(page.to_dict(exclude=["name"]))
        else:
            self.abort(404)
Exemple #6
0
  def post(self, name):
    """Handles the post requests for edit page of the wiki pages

    The user will get redirected to the SignupPage if authentication fails.

    The entity will be stored and the user gets redirected to the new version of
    the page.
    """
    self.restrictedArea()
    name = utils.checkPage(name)

    page = Page.createPage(name, self.request.get('content'), self.user.name)
    page.put()

    utils.addSearchIndex(page)
    
    self.redirect('/%s' % name)