コード例 #1
0
ファイル: main.py プロジェクト: GunioRobot/Social-Guidebook
  def post(self):
    self.acl.check_edit_pages()

    name = self.request.get('name')
    body = self.request.get('body')

    title = pages.get_title(pages.wikifier(self.settings).wikify(body))
    if not name:
      name = title

    page = pages.get(name, create=True)
    page.body = body
    page.title = title
    page.author = self.get_wiki_user(True)
    if not page.author and users.get_current_user():
      raise Exception('Could not determine who you are.')
    if self.request.get('pread'):
      page.pread = True
    else:
      page.pread = False
    pages.put(page)

    # Remove old page from cache.
    pages.cache.update(name)

    self.redirect('/' + pages.quote(page.title))
コード例 #2
0
ファイル: main.py プロジェクト: GunioRobot/Social-Guidebook
  def get_page_content(self, page_title, revision_number=1):
    """When memcache lookup fails, we want to query the information from
       the datastore and return it.  If the data isn't in the data store,
       simply return empty strings
    """
    # Find the wiki entry
    entry = WikiContent.gql('WHERE title = :1', self.get_page_name(page_title)).get()

    if entry:
      # Retrieve the current version
      if revision_number is not None:
          requested_version = WikiRevision.gql('WHERE wiki_page =  :1 '
                                               'AND version_number = :2', entry, int(revision_number)).get()
      else:
          requested_version = WikiRevision.gql('WHERE wiki_page =  :1 '
                                               'ORDER BY version_number DESC', entry).get()
      # Define the body, version number, author email, author nickname
      # and revision date
      body = requested_version.revision_body
      version = requested_version.version_number
      author_email = urllib.quote(requested_version.author.wiki_user.email())
      author_nickname = requested_version.author.wiki_user.nickname()
      version_date = requested_version.created
      # Replace all wiki words with links to those wiki pages
      wiki_body = pages.wikifier(self.settings).wikify(body)
      pread = requested_version.pread
    else:
      # These things do not exist
      wiki_body = ''
      author_email = ''
      author_nickname = ''
      version = ''
      version_date = ''
      pread = False

    return [wiki_body, author_email, author_nickname, version, version_date, pread]