Beispiel #1
0
def main():
    """ The main MokshaHub method """
    setup_logger('-v' in sys.argv or '--verbose' in sys.argv)
    config_path = get_moksha_config_path()
    if not config_path:
        print """
            Cannot find Moksha configuration!  Place a development.ini or production.ini
            in /etc/moksha or in the current directory.
        """
        return
    cfg = appconfig('config:' + config_path)
    config.update(cfg)

    hub = CentralMokshaHub()
    global _hub
    _hub = hub

    def handle_signal(signum, stackframe):
        from moksha.hub.reactor import reactor
        if signum in [signal.SIGHUP, signal.SIGINT]:
            hub.stop()
            try:
                reactor.stop()
            except ReactorNotRunning:
                pass

    signal.signal(signal.SIGHUP, handle_signal)
    signal.signal(signal.SIGINT, handle_signal)

    log.info("Running the MokshaHub reactor")
    reactor.run(installSignalHandlers=False)
    log.info("MokshaHub reactor stopped")
Beispiel #2
0
def main():
    """ The main MokshaHub method """
    setup_logger('-v' in sys.argv or '--verbose' in sys.argv)
    config_path = get_moksha_config_path()
    if not config_path: 
        print """
            Cannot find Moksha configuration!  Place a development.ini or production.ini
            in /etc/moksha or in the current directory.
        """
        return
    cfg = appconfig('config:' + config_path)
    config.update(cfg)

    hub = CentralMokshaHub()
    global _hub
    _hub = hub

    def handle_signal(signum, stackframe):
        from moksha.hub.reactor import reactor
        if signum in [signal.SIGHUP, signal.SIGINT]:
            hub.stop()
            try:
                reactor.stop()
            except ReactorNotRunning:
                pass

    signal.signal(signal.SIGHUP, handle_signal)
    signal.signal(signal.SIGINT, handle_signal)

    log.info("Running the MokshaHub reactor")
    reactor.run(installSignalHandlers=False)
    log.info("MokshaHub reactor stopped")
Beispiel #3
0
# the developer. Basically, it grabs the current variable_provider from the
# config, puts the tgext.menu variable provider into the config, and then
# returns the results from its own plus the original variable provider.
#
# By doing this, the developer does not have to remember to update the
# variable provider to provide the functions that the README says should be
# available in all templates.
def menu_variable_provider():
    menu_vars = Bunch (
        url_from_menu = url_from_menu,
        render_menu = render_menu,
        render_navbar = render_navbar,
        render_sidebar = render_sidebar,
    )
    
    try:
        from genshi import HTML
        menu_vars['HTML'] = HTML
    except ImportError:
        pass
    
    if app_variable_provider:
        menu_vars.update(app_variable_provider())

    return menu_vars

app_variable_provider = config.get('tgext_menu_sub_variable_provider', None)
config.update(Bunch(
    variable_provider = menu_variable_provider
    ))