diff --git a/CHANGELOG.md b/CHANGELOG.md index ba15691..f28bedf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,6 @@ All notable changes to wuttaweb will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## v0.2.0 (2024-07-14) - -### Feat - -- add basic support for menu handler - -- add "web handler" feature; it must get the menu handler - ## v0.1.0 (2024-07-12) ### Feat diff --git a/docs/api/wuttaweb/handler.rst b/docs/api/wuttaweb/handler.rst deleted file mode 100644 index 0209473..0000000 --- a/docs/api/wuttaweb/handler.rst +++ /dev/null @@ -1,6 +0,0 @@ - -``wuttaweb.handler`` -==================== - -.. automodule:: wuttaweb.handler - :members: diff --git a/docs/api/wuttaweb/index.rst b/docs/api/wuttaweb/index.rst index 2e49d4b..673a6df 100644 --- a/docs/api/wuttaweb/index.rst +++ b/docs/api/wuttaweb/index.rst @@ -8,7 +8,6 @@ :maxdepth: 1 app - handler helpers menus static diff --git a/docs/index.rst b/docs/index.rst index 8a7bc0a..b012584 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,11 +6,6 @@ This package provides a "web layer" for custom apps. It uses traditional server-side rendering with VueJS on the front-end. -Good documentation and 100% `test coverage`_ are priorities for this -project. - -.. _test coverage: https://buildbot.rattailproject.org/coverage/wuttaweb/ - .. toctree:: :maxdepth: 3 :caption: Contents: diff --git a/pyproject.toml b/pyproject.toml index 985bef5..a623b4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttaWeb" -version = "0.2.0" +version = "0.1.0" description = "Web App for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] @@ -35,7 +35,7 @@ dependencies = [ "pyramid_mako", "waitress", "WebHelpers2", - "WuttJamaican[db]>=0.7.0", + "WuttJamaican[db]>=0.6.1", ] @@ -48,14 +48,14 @@ tests = ["pytest-cov", "tox"] main = "wuttaweb.app:main" -[project.entry-points."wutta.app.providers"] +[project.entry-points."wutta.providers"] wuttaweb = "wuttaweb.app:WebAppProvider" [project.urls] -Homepage = "https://wuttaproject.org/" -Repository = "https://forgejo.wuttaproject.org/wutta/wuttaweb" -Changelog = "https://forgejo.wuttaproject.org/wutta/wuttaweb/src/branch/master/CHANGELOG.md" +Homepage = "https://rattailproject.org/" +Repository = "https://kallithea.rattailproject.org/rattail-project/wuttaweb" +Changelog = "https://kallithea.rattailproject.org/rattail-project/wuttaweb/files/master/CHANGELOG.md" [tool.commitizen] diff --git a/src/wuttaweb/app.py b/src/wuttaweb/app.py index 18b07fb..ff9d37f 100644 --- a/src/wuttaweb/app.py +++ b/src/wuttaweb/app.py @@ -34,28 +34,28 @@ from pyramid.config import Configurator class WebAppProvider(AppProvider): """ - The :term:`app provider` for WuttaWeb. This adds some methods - specific to web apps. + The :term:`app provider` for WuttaWeb. This adds + some methods to get web-specific :term:`handlers`. """ - def get_web_handler(self, **kwargs): + def get_web_menu_handler(self, **kwargs): """ - Get the configured "web" handler for the app. + Get the configured "menu" handler for the web app. Specify a custom handler in your config file like this: .. code-block:: ini - [wutta] - web.handler_spec = poser.web.handler:PoserWebHandler + [wuttaweb] + menus.handler_spec = poser.web.menus:PoserMenuHandler - :returns: Instance of :class:`~wuttaweb.handler.WebHandler`. + :returns: Instance of :class:`~wuttaweb.menus.MenuHandler`. """ - if 'web_handler' not in self.__dict__: - spec = self.config.get(f'{self.appname}.web.handler_spec', - default='wuttaweb.handler:WebHandler') - self.web_handler = self.app.load_object(spec)(self.config) - return self.web_handler + if 'web_menu_handler' not in self.__dict__: + spec = self.config.get('wuttaweb.menus.handler_spec', + default='wuttaweb.menus:MenuHandler') + self.web_menu_handler = self.app.load_object(spec)(self.config) + return self.web_menu_handler def make_wutta_config(settings): diff --git a/src/wuttaweb/handler.py b/src/wuttaweb/handler.py deleted file mode 100644 index d0fa704..0000000 --- a/src/wuttaweb/handler.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8; -*- -################################################################################ -# -# wuttaweb -- Web App for Wutta Framework -# Copyright © 2024 Lance Edgar -# -# This file is part of Wutta Framework. -# -# Wutta Framework is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) any -# later version. -# -# Wutta Framework is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# Wutta Framework. If not, see . -# -################################################################################ -""" -Web Handler - -This defines the :term:`handler` for the web layer. -""" - -from wuttjamaican.app import GenericHandler - - -class WebHandler(GenericHandler): - """ - Base class and default implementation for the "web" :term:`handler`. - - This is responsible for determining the "menu handler" and - (eventually) possibly other things. - """ - - def get_menu_handler(self, **kwargs): - """ - Get the configured "menu" handler for the web app. - - Specify a custom handler in your config file like this: - - .. code-block:: ini - - [wutta.web] - menus.handler_spec = poser.web.menus:PoserMenuHandler - - :returns: Instance of :class:`~wuttaweb.menus.MenuHandler`. - """ - if not hasattr(self, 'menu_handler'): - spec = self.config.get(f'{self.appname}.web.menus.handler_spec', - default='wuttaweb.menus:MenuHandler') - self.menu_handler = self.app.load_object(spec)(self.config) - return self.menu_handler diff --git a/src/wuttaweb/menus.py b/src/wuttaweb/menus.py index c0e7ae1..37625a5 100644 --- a/src/wuttaweb/menus.py +++ b/src/wuttaweb/menus.py @@ -138,7 +138,7 @@ class MenuHandler(GenericHandler): The web app calls this method but you normally should not need to override it; you can override :meth:`make_menus()` instead. """ - raw_menus = self._make_raw_menus(request, **kwargs) + raw_menus = self.make_menus(request, **kwargs) # now we have "simple" (raw) menus definition, but must refine # that somewhat to produce our final menus @@ -209,16 +209,6 @@ class MenuHandler(GenericHandler): return final_menus - def _make_raw_menus(self, request, **kwargs): - """ - Construct the initial full set of "raw" menus. - - For now this just calls :meth:`make_menus()` which generally - means a "hard-coded" menu set. Eventually it may allow for - loading dynamic menus from config instead. - """ - return self.make_menus(request, **kwargs) - def _is_allowed(self, request, item): """ Logic to determine if a given menu item is "allowed" for diff --git a/src/wuttaweb/subscribers.py b/src/wuttaweb/subscribers.py index 314922b..860942f 100644 --- a/src/wuttaweb/subscribers.py +++ b/src/wuttaweb/subscribers.py @@ -36,16 +36,12 @@ hooks contained here, depending on the circumstance. """ import json -import logging from pyramid import threadlocal from wuttaweb import helpers -log = logging.getLogger(__name__) - - def new_request(event): """ Event hook called when processing a new request. @@ -133,7 +129,6 @@ def before_render(event): request = event.get('request') or threadlocal.get_current_request() config = request.wutta_config app = config.get_app() - web = app.get_web_handler() context = event context['app'] = app @@ -142,7 +137,7 @@ def before_render(event): context['url'] = request.route_url context['json'] = json - menus = web.get_menu_handler() + menus = app.get_web_menu_handler() context['menus'] = menus.do_make_menus(request) diff --git a/tasks.py b/tasks.py index 4635a82..b6084de 100644 --- a/tasks.py +++ b/tasks.py @@ -15,7 +15,7 @@ def release(c, skip_tests=False): Release a new version of WuttJamaican """ if not skip_tests: - c.run('pytest') + c.run('tox') # rebuild pkg if os.path.exists('dist'): diff --git a/tests/test_handler.py b/tests/test_handler.py deleted file mode 100644 index 79a0a64..0000000 --- a/tests/test_handler.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8; -*- - -from unittest import TestCase - -from wuttjamaican.conf import WuttaConfig - -from wuttaweb import handler as mod -from wuttaweb.menus import MenuHandler - - -class TestWebHandler(TestCase): - - def setUp(self): - self.config = WuttaConfig() - self.app = self.config.get_app() - self.handler = mod.WebHandler(self.config) - - def test_menu_handler_default(self): - menus = self.handler.get_menu_handler() - self.assertIsInstance(menus, MenuHandler) diff --git a/tests/test_menus.py b/tests/test_menus.py index 27d45b9..68cec31 100644 --- a/tests/test_menus.py +++ b/tests/test_menus.py @@ -159,12 +159,6 @@ class TestMenuHandler(TestCase): self.assertTrue(entry['is_sep']) self.assertFalse(entry['is_menu']) - def test_make_raw_menus(self): - # minimal test to ensure it calls the other method - with patch.object(self.handler, 'make_menus') as make_menus: - self.handler._make_raw_menus(self.request, foo='bar') - make_menus.assert_called_once_with(self.request, foo='bar') - def test_do_make_menus_prune_unallowed_item(self): test_menus = [ {