예제 #1
0
def useDefaultLoggingNotification(all=True, **kwargs):
    '''The kwargs are the same as for PubsubTopicMsgLogger constructor, except
    that 'all' defaults to True instead of None (ie assumes that if you
    don't specify what notifications you want, that you want them all).'''
    import pubsub.utils
    notifHandler = pubsub.utils.NotifyByPubsubMessage()
    import pubsubconf
    pubsubconf.setNotificationHandler(notifHandler)

    from pubsub import pub
    notifHandler.createNotificationTopics()
    pub.setNotification(all=all, **kwargs)

    return PubsubTopicMsgLogger(pub)
예제 #2
0
def useNotifyByPubsubMessage():
    '''Install an instance of NotifyByPubsubMessage as notification
    handler. Return the instance. You must call its init() once
    pubsub imported (since instance defines some pubsub topics):

    import pubsub.utils
    notifHandler = pubsub.utils.useNotifyByPubsubMessage()

    ...

    from pubsub import pub
    notifHandler.createNotificationTopics()
    '''
    import pubsub.utils
    notifHandler = pubsub.utils.NotifyByPubsubMessage()
    import pubsubconf
    pubsubconf.setNotificationHandler(notifHandler)

    return notifHandler