Ejemplo n.º 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)
Ejemplo n.º 2
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)