Coverage for .tox/coverage/lib/python3.11/site-packages/wuttaweb/handler.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-05 15:42 -0500

1# -*- coding: utf-8; -*- 

2################################################################################ 

3# 

4# wuttaweb -- Web App for Wutta Framework 

5# Copyright © 2024 Lance Edgar 

6# 

7# This file is part of Wutta Framework. 

8# 

9# Wutta Framework is free software: you can redistribute it and/or modify it 

10# under the terms of the GNU General Public License as published by the Free 

11# Software Foundation, either version 3 of the License, or (at your option) any 

12# later version. 

13# 

14# Wutta Framework is distributed in the hope that it will be useful, but 

15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 

16# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 

17# more details. 

18# 

19# You should have received a copy of the GNU General Public License along with 

20# Wutta Framework. If not, see <http://www.gnu.org/licenses/>. 

21# 

22################################################################################ 

23""" 

24Web Handler 

25 

26This defines the :term:`handler` for the web layer. 

27""" 

28 

29from wuttjamaican.app import GenericHandler 

30 

31 

32class WebHandler(GenericHandler): 

33 """ 

34 Base class and default implementation for the "web" :term:`handler`. 

35 

36 This is responsible for determining the "menu handler" and 

37 (eventually) possibly other things. 

38 """ 

39 

40 def get_menu_handler(self, **kwargs): 

41 """ 

42 Get the configured "menu" handler for the web app. 

43 

44 Specify a custom handler in your config file like this: 

45 

46 .. code-block:: ini 

47 

48 [wutta.web] 

49 menus.handler_spec = poser.web.menus:PoserMenuHandler 

50 

51 :returns: Instance of :class:`~wuttaweb.menus.MenuHandler`. 

52 """ 

53 if not hasattr(self, 'menu_handler'): 

54 spec = self.config.get(f'{self.appname}.web.menus.handler_spec', 

55 default='wuttaweb.menus:MenuHandler') 

56 self.menu_handler = self.app.load_object(spec)(self.config) 

57 return self.menu_handler