~madjar/wikkid/plugin

« back to all changes in this revision

Viewing changes to wikkid/view/wiki.py

  • Committer: Tim Penhey
  • Date: 2010-06-23 12:18:38 UTC
  • mfrom: (41.2.47 webob)
  • Revision ID: tim@penhey.net-20100623121838-30s9cl039ws3cpup
Replace the twisted implementation with a WSGI one using webob.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
"""View classes to control the rendering of wiki pages."""
8
8
 
9
 
from bzrlib.osutils import format_date
10
 
 
11
 
from twisted.web.util import redirectTo
 
9
from webob.exc import HTTPTemporaryRedirect
12
10
 
13
11
from wikkid.formatter.registry import get_wiki_formatter
14
12
from wikkid.interface.resource import IWikiTextFile
32
30
        content, formatter = get_wiki_formatter(bytes, 'rest')
33
31
        return formatter.format(self.context.base_name, content)
34
32
 
35
 
    @property
36
 
    def last_modified_by(self):
37
 
        return self.context.last_modified_by
38
 
 
39
 
    @property
40
 
    def last_modified_date(self):
41
 
        return self.context.last_modified_date.strftime(
42
 
            '%Y-%m-%d %H:%M:%S')
43
 
 
44
33
    def _render(self, skin):
45
34
        """If the page is not being viewed with the preferred path, redirect.
46
35
 
48
37
        """
49
38
        preferred = self.context.preferred_path
50
39
        if self.context.path != preferred:
51
 
            return redirectTo(preferred, self.request)
 
40
            raise HTTPTemporaryRedirect(location=preferred)
52
41
        else:
53
42
            return super(WikiPage, self)._render(skin)