source: MILK/trunk/milk_server/milk_server/controllers/ @ 5158

Subversion URL:
Revision 5158, 1.2 KB checked in by cbyrom, 11 years ago (diff)

Add new home page for the browse service + implement usage of the
before methods on controllers to check if MILK is set up to
allow the various services before the controller methods are invoked.
Also add a top level default controller to redirect user to the correct
home page depending on the mode of operation + improve styles,
remove unused controller and move error template to more general top
level - for re-use across the MILK stack.

2 Fall back controller, to render a home page for the service depending on what
3 mode it is running in - NB, if multiple modes are enabled, the order of preference,
4 from highest to lowest, is editor, discovery, browser
6 @author: C Byrom, Tessella Apr 2009
8from milk_server.lib.base import *
9from milk_server.models.ndgdoc import NDGDoc
10from ndg.common.src.models.ndgObject import ndgObject
11import ndg.common.src.clients.xmldb.eXist.dbconstants as dc
12from ndg.common.src.lib.mailer import mailHandler
14class HomeController(BaseController):
15    '''
16    Sets up appropriate home page for fall through urls
17    '''
18    def index(self):
19        '''
20        Redirect to the appropriate home page - or display error
21        '''
22        if g.atomEditorEnabled:
23            h.redirect_to(h.url_for('atomHome'))
24        elif g.discoveryEnabled:
25            h.redirect_to(h.url_for('discovery'))
26        elif g.browseEnabled:
27            h.redirect_to(h.url_for('browseHome'))
28        else:
29            c.title = "No service enabled"
30            c.xml = "The server should be configured to provide one or more of the followings client services: editor, discovery or browse."
31            return render("genshi", 'error')
Note: See TracBrowser for help on using the repository browser.