Changeset 17327


Ignore:
Timestamp:
31 Jan 2023, 16:15:54 (22 months ago)
Author:
uli
Message:

Upgrade grokcore.startup

while still keeping the possibility to use zdaemon. This change requires
rerunning buildout.

Location:
main/waeup.kofa/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r17313 r17327  
    55=======================
    66
     7* Move call to interactive debugger from `grokcore.startup` to `waeup.kofa`.
     8  Support for this was dropped long ago in `grokcore.startup`. This way we keep
     9  the possibility to provide a `kofactl` script w/o loosing the possibility to
     10  upgrade to newer `grokcore.startup` versions.
     11
    712* Allow beds to be blocked so that no student can be allocated to such a bed space
    813  (in contrast to reserved beds)
     
    14191.8.1 (2023-01-16)
    1520==================
    16 
    1721
    1822* Upgrade `dolmen.beaker` dependency. Removes other outdated crypto
     
    3034
    3135* Allow students to book accommodation also if they are in previous
    32   sessions (not activated in base package). 
    33 
    34 * Add Javascript which automatically submits a form on select change 
     36  sessions (not activated in base package).
     37
     38* Add Javascript which automatically submits a form on select change
    3539  (not used in base but in lpng custom package).
    3640
     
    6670* Enable import of student history.
    6771
    68 * Don't complain but remove leading and trailing whitespaces 
     72* Don't complain but remove leading and trailing whitespaces
    6973  while converting values during import.
    7074
     
    8993* Prefill login form after applicant registration.
    9094
    91 * Show local roles on faculty, department, course and certificate pages 
    92   and provide 'Contact' button so that authenticated users can contact 
     95* Show local roles on faculty, department, course and certificate pages
     96  and provide 'Contact' button so that authenticated users can contact
    9397  officers via Kofa.
    9498
     
    257261* Make max file size customizable.
    258262
    259 * Add `score_editing_disabled` switch at course level. 
     263* Add `score_editing_disabled` switch at course level.
    260264
    261265* Take `DELETION_MARKER` into consideration when updating passwords.
     
    275279  in container code.
    276280
    277 * Add semester filter to Fix `CourseTicketExporter`. 
     281* Add semester filter to Fix `CourseTicketExporter`.
    278282
    279283* Add `FacultiesExportJobContainerSelectStudents` view to allow
  • main/waeup.kofa/trunk/setup.py

    r17299 r17327  
    132132      [console_scripts]
    133133      kofa-debug = grokcore.startup:interactive_debug_prompt
    134       kofactl = grokcore.startup:zdaemon_controller
     134      kofactl = waeup.kofa.startup:zdaemon_controller
    135135      analyze = waeup.kofa.maintenance:db_analyze
    136136      fsdiff = waeup.kofa.maintenance:db_diff
  • main/waeup.kofa/trunk/src/waeup/kofa/startup.py

    r12110 r17327  
    4949"""
    5050import os
     51import sys
     52import zdaemon.zdctl
    5153from ConfigParser import RawConfigParser
    52 from grokcore.startup import application_factory, debug_application_factory
     54from grokcore.startup import (
     55        application_factory, debug_application_factory,
     56        interactive_debug_prompt)
     57
    5358
    5459def _set_env_vars(global_conf):
     
    6267        os.environ[key] = val
    6368    return
     69
    6470
    6571def env_app_factory(global_conf, **local_conf):
     
    94100    return application_factory(global_conf, **local_conf)
    95101
     102
    96103def env_debug_app_factory(global_conf, **local_conf):
    97104    """A debugger application factory.
     
    104111    _set_env_vars(global_conf)
    105112    return debug_application_factory(global_conf, **local_conf)
     113
     114
     115class ControllerCommands(zdaemon.zdctl.ZDCmd):
     116
     117    def do_debug(self, rest):
     118        zope_conf = os.path.join('parts', 'etc', 'zope.conf')
     119        del sys.argv[0]
     120        interactive_debug_prompt(zope_conf=zope_conf)
     121
     122    def help_debug(self):
     123        print("debug -- Initialize the application, providing a debugger")
     124        print("         object at an interactive Python prompt.")
     125
     126
     127def zdaemon_controller(zdaemon_conf=os.path.join('parts', 'etc',
     128                                                 'zdaemon.conf')):
     129    args = ['-C', zdaemon_conf] + sys.argv[1:]
     130    zdaemon.zdctl.main(args, options=None, cmdclass=ControllerCommands)
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_startup.py

    r12110 r17327  
    11# Tests for local startup functions.
     2import mock
    23import os
    34import shutil
     5import sys
    46import tempfile
    57import unittest
     8# from zdaemon.zdctl import
     9import zdaemon.zdctl
    610from zope.app.wsgi import WSGIPublisherApplication
    7 from waeup.kofa.startup import env_app_factory, env_debug_app_factory
     11# from zdaemon.tests.testzdctl import run as run_zdctl
     12from waeup.kofa.startup import (
     13        env_app_factory, env_debug_app_factory, zdaemon_controller,
     14        )
     15try:
     16    from StringIO import StringIO  # py2
     17except ImportError:
     18    from io import StringIO        # py3
     19
     20
    821
    922ZOPE_CONF_TEMPL = '''
     
    2134'''
    2235
     36
     37ZDAEMON_CONF_TEMPL = '''
     38<runner>
     39  program echo "zdaemon started"
     40</runner>
     41'''
     42
     43
    2344class StartUpTests(unittest.TestCase):
    2445
     
    2950        self.zope_conf = os.path.join(self.workdir, 'zope.conf')
    3051        open(self.zope_conf, 'wb').write(ZOPE_CONF_TEMPL % self.site_zcml)
     52        self.zdaemon_conf = os.path.join(self.workdir, 'zdaemon.conf')
     53        open(self.zdaemon_conf, 'wb').write(ZDAEMON_CONF_TEMPL)
    3154        return
    3255
     
    7598        self.assertEqual(os.environ.get('TEST_FOO', None), 'value1')
    7699        return
     100
     101    @mock.patch("sys.stdout", new_callable=StringIO)
     102    def test_zdaemon_has_debug_help(self, mock_out):
     103        # We provide a `debug` help text for `kofactl`
     104        with mock.patch.object(sys, "argv", ["kofactl",  "help", "debug"]):
     105            with self.assertRaises(SystemExit):
     106                zdaemon_controller(zdaemon_conf=self.zdaemon_conf)
     107        self.assertTrue("providing a debugger" in mock_out.getvalue())
     108
     109    @mock.patch("waeup.kofa.startup.interactive_debug_prompt")
     110    def test_zdaemon_can_start_debug(self, mock_prompt):
     111        # We can actually run the debugger...
     112        with mock.patch.object(sys, "argv", ["kofactl", "debug"]):
     113            with self.assertRaises(SystemExit):
     114                zdaemon_controller(zdaemon_conf=self.zdaemon_conf)
     115        self.assertTrue(mock_prompt.called)
  • main/waeup.kofa/trunk/versions.cfg

    r17307 r17327  
    8484zc.z3monitor = 0.8.0
    8585zc.zodbrecipes = 0.6.2
    86 zdaemon = 2.0.7
     86zdaemon = 4.4
    8787ZODB3 = 3.10.5
    8888zope.app.apidoc = 3.7.5
     
    160160
    161161# Packages already at newest version (supporting py2 and py3)
     162grokcore.startup = 3.0.1
    162163Paste = 3.5.2
    163164PasteScript = 3.3.0
Note: See TracChangeset for help on using the changeset viewer.