1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
# Copyright 2012 Sloecode Developers
20
from sloecode.wikkidviewadapters.wiki import WikiViewAdapter
21
from sloecode.wikkidviewadapters.missing_page import MissingPageViewAdapter
22
from sloecode.wikkidviewadapters.edit import EditTextViewAdapter
23
from sloecode.wikkidviewadapters.directory import DirectoryViewAdapter
24
from sloecode.wikkidviewadapters.source_text import SourceTextViewAdapter
25
from sloecode.wikkidviewadapters.root import RootViewAdapter
27
log = logging.getLogger(__name__)
29
class ViewAdapterFactory(object):
33
'DirectoryListingPage' : DirectoryViewAdapter,
34
'MissingPage' : MissingPageViewAdapter,
35
'MissingDirectory' : MissingPageViewAdapter,
36
'NewWikiPage' : EditTextViewAdapter,
37
'RootPage' : RootViewAdapter,
38
'SourceTextPage' : SourceTextViewAdapter,
39
'EditTextFile' : EditTextViewAdapter,
40
'UpdateTextFile': EditTextViewAdapter,
41
'SaveNewTextFile': EditTextViewAdapter,
42
'WikiPage' : WikiViewAdapter
45
def get_view_adapter(self, app, environ):
47
Returns an instance of the correct type
48
of view adapter based on the parsed environ.
49
Returns None if view is not in dictionary.
51
view = app.get_view(environ)
52
log.info("View: %s"%view.__class__.__name__)
53
if view.__class__.__name__ in self._view_map:
54
return self._view_map[view.__class__.__name__]()
57
def get_specified_adapter(self, viewName):
58
if viewName in self._view_map:
59
return self._view_map[viewName]()
b'\\ No newline at end of file'