def test_application_defaults(self):
        new_proxy = ApplicationDefaultsProxy()
        eq_(new_proxy.application_defaults, DotDict())

        new_proxy.str_to_application_class(
            'collector.unittest.app.test_for_application_defaults.SomeApp')

        eq_(dict(new_proxy.application_defaults), {
            'alpha': 17,
            'beta': 23,
        })
 def test_get_values(self):
     new_proxy = ApplicationDefaultsProxy()
     vs = ValueSource(new_proxy)
     eq_(vs.get_values(None, None, dict), {})
     eq_(vs.get_values(None, None, DotDict), DotDict())
     new_proxy.str_to_application_class(
         'collector.unittest.app.test_for_application_defaults.SomeApp')
     eq_(vs.get_values(None, None, dict), {
         'alpha': 17,
         'beta': 23,
     })
     ok_(isinstance(vs.get_values(None, None, DotDict), DotDict))
 def setUp(self):
     self.proxy = ApplicationDefaultsProxy()
# ApplicationDefaultsProxy object is already in the values source list, it can
# then start providing overlay values immediately.

# Configman knows nothing about how the ApplicationDefaultsProxy object works,
# so we must regisiter it as a new values overlay source class.  We do that
# by manually inserting inserting the new class into Configman's
# handler/dispatcher.  That object associates config sources with modules that
# are able to implement Configman's overlay handlers.
from configman.value_sources import type_handler_dispatch
# register our new type handler with configman
type_handler_dispatch[ApplicationDefaultsProxy].append(
    collector.app.for_application_defaults)

#------------------------------------------------------------------------------
# create the app default proxy object
application_defaults_proxy = ApplicationDefaultsProxy()

#------------------------------------------------------------------------------
# for use with SIGHUP for apps that run as daemons
restart = True


#------------------------------------------------------------------------------
def respond_to_SIGHUP(signal_number, frame, logger=None):
    """raise the KeyboardInterrupt which will cause the app to effectively
    shutdown, closing all it resources.  Then, because it sets 'restart' to
    True, the app will reread all the configuration information, rebuild all
    of its structures and resources and start running again"""
    global restart
    restart = True
    if logger: