예제 #1
0
파일: wiki.py 프로젝트: vcelis/cs253-wiki
  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)
예제 #2
0
파일: wiki.py 프로젝트: vcelis/cs253-wiki
  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)
예제 #3
0
파일: api.py 프로젝트: vcelis/cs253-wiki
    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)