From: Karl O. Pinc Date: Wed, 24 Oct 2018 02:22:03 +0000 (-0500) Subject: New includeme() configuration callable X-Git-Url: https://papio.biology.duke.edu/gitweb/?a=commitdiff_plain;h=5077f717d32f9c6c45469d83e688ea1abc329db8;p=pgwui_common New includeme() configuration callable --- diff --git a/setup.py b/setup.py index 75c84d1..cb3feea 100644 --- a/setup.py +++ b/setup.py @@ -131,7 +131,10 @@ setup( package_dir={'': 'src'}, # Run-time dependencies. - install_requires=[], + install_requires=[ + 'pyramid_beaker', + 'pyramid_mako', + ], # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax, diff --git a/src/pgwui_common/configure.py b/src/pgwui_common/configure.py new file mode 100644 index 0000000..52c820f --- /dev/null +++ b/src/pgwui_common/configure.py @@ -0,0 +1,40 @@ +# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ + +# This file is part of PGWUI_Common. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program 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 +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# + +# Karl O. Pinc + +'''Provide a way to configure PGWUI. + +To use pgwui_common configure your pyramid app by putting the +following into your package's __init__.py: + + from pyramid.config import Configurator + + def main(global_config, **settings): + config = Configurator() + config.include('pgwui_common.configure.includeme') + +''' + + +def includeme(config): + config.include('pyramid_mako') + config.include('pyramid_beaker') + config.add_static_view( + 'static', 'pgwui_common:/static', cache_max_age=3600) diff --git a/src/pgwui_common/pgwui_common.py b/src/pgwui_common/pgwui_common.py deleted file mode 100644 index 205c4eb..0000000 --- a/src/pgwui_common/pgwui_common.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ - -# This file is part of PGWUI_Common. -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program 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 -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -# - -# Karl O. Pinc - -'''Empty module. -''' - - -def example_func(): - return 1 diff --git a/tests/test_configure.py b/tests/test_configure.py new file mode 100644 index 0000000..ca4eaa6 --- /dev/null +++ b/tests/test_configure.py @@ -0,0 +1,41 @@ +# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ + +# This file is part of PGWUI_Common. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program 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 +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# + +# Karl O. Pinc + +from pgwui_common import configure + + +def test_configure_includecalled(): + + class MockConfig(): + def __init__(self): + self.include_called = False + self.add_static_view_called = False + + def include(self, *args): + self.include_called = True + + def add_static_view(self, *args, **kwargs): + self.add_static_view_called = True + + config = MockConfig() + configure.includeme(config) + assert config.include_called + assert config.add_static_view_called diff --git a/tests/test_pgwui_common.py b/tests/test_pgwui_common.py deleted file mode 100644 index c0fca96..0000000 --- a/tests/test_pgwui_common.py +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2018 The Meme Factory, Inc. http://www.meme.com/ - -# This file is part of PGWUI_Common. -# -# This program is free software: you can redistribute it and/or -# modify it under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation, either version 3 of -# the License, or (at your option) any later version. -# -# This program 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 -# Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -# - -# Karl O. Pinc - -from pgwui_common import pgwui_common - - -def test_example_func(): - assert pgwui_common.example_func() == 1