1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# -*- coding: utf-8 -*-
#
# Copyright (C) 2010 Wikkid Developers
#
# This software is licensed under the GNU Affero General Public License
# version 3 (see the file LICENSE).
"""View classes to control the rendering of the content."""
from wikkid.interface.resource import IMissingResource
from wikkid.view.base import BaseView
from wikkid.view.edit import BaseEditView
from wikkid.view.textfile import SaveNewTextContent
class BaseMissingView(BaseView):
"""A base view for +view and +listing.
This view just makes the results actual 404s.
"""
def make_response(self, body):
response = super(BaseMissingView, self).make_response(body)
response.status = "404 Not Found"
return response
class MissingPage(BaseMissingView):
"""A wiki page that does not exist."""
for_interface = IMissingResource
name = 'view'
is_default = True
template = 'missing'
@property
def content(self):
'%s Not found' % self.path
class MissingDirectory(BaseMissingView):
"""A wiki directory that does not exist."""
for_interface = IMissingResource
name = 'listing'
template = 'missing-dir'
@property
def content(self):
'%s Not found' % self.path
class NewWikiPage(BaseEditView):
"""Show the edit page with no existing content."""
for_interface = IMissingResource
@property
def rev_id(self):
return None
@property
def content(self):
return ''
class SaveNewTextFile(SaveNewTextContent):
for_interface = IMissingResource
|