Exemplo n.º 1
0
def pushy_post_save(sender, **kwargs):

    if kwargs.get('raw'):
        return

    rs = redis.StrictRedis(host=pushy_settings.get_redis_host())
    obj = kwargs['instance']
    created = kwargs['created']

    try:
        pushy_ignore = obj._pushy_ignore
    except:
        pushy_ignore = False

    if pushy_ignore:
        return

    if created:
        action = 'create'
        try:
            route = obj.get_api_list_url()
        except:
            route = obj.get_api_url()
    else:
        action = 'update'
        route = obj.get_api_url()

    message = {'route': route, 'type': action}
    log.debug('Routing message to: %s' % pushy_settings.get_channel())
    log.debug('route: %s' % route)

    #pushy_publish(pushy_settings.get_channel(), 'update', message)
    pool.apply_async(
        pushy_publish(pushy_settings.get_channel(), action, message))
Exemplo n.º 2
0
def pushy_post_save(sender, **kwargs):
    rs = redis.StrictRedis(host=pushy_settings.get_redis_host())
    obj = kwargs['instance']
    created = kwargs['created']


    try:
        pushy_ignore = obj._pushy_ignore
    except:
        pushy_ignore = False

    if pushy_ignore:
        return

    if created:
        action = 'create'
        try:
            route = obj.get_api_list_url()
        except:
            route = obj.get_api_url()
    else:
        action = 'update'
        route = obj.get_api_url()

    message = {
               'route': route,
               'type': action
               }
    logger.debug('Routing message to: %s' % pushy_settings.get_channel())
    logger.debug('route: %s' % route)

    #pushy_publish(pushy_settings.get_channel(), 'update', message)
    pool.apply_async(pushy_publish(pushy_settings.get_channel(), action, message))
Exemplo n.º 3
0
def pushy_post_delete(sender, **kwargs):
    rs = redis.StrictRedis(host=pushy_settings.get_redis_host())
    obj = kwargs['instance']

    message = {'route': obj.get_api_url(), 'type': 'delete'}
    log.debug('Routing message to: %s' % pushy_settings.get_channel())
    log.debug('route: %s' % obj.get_api_url())

    pool.apply_async(
        pushy_publish(pushy_settings.get_channel(), 'delete', message))
Exemplo n.º 4
0
def pushy_post_delete(sender, **kwargs):
    rs = redis.StrictRedis(host=pushy_settings.get_redis_host())
    obj = kwargs['instance']

    message = {
               'route': obj.get_api_url(),
               'type': 'delete'
               }
    log.debug('Routing message to: %s' % pushy_settings.get_channel())
    log.debug('route: %s' % obj.get_api_url())

    pool.apply_async(pushy_publish(pushy_settings.get_channel(), 'delete', message))
Exemplo n.º 5
0
def pushy_publish(channel, key, message):
    rs = redis.StrictRedis(host=pushy_settings.get_redis_host())
    time.sleep(0.005)
    return rs.publish('%s%s' % (channel, key), json.dumps(message))
Exemplo n.º 6
0
def pushy_publish(channel, key, message):
    rs = redis.StrictRedis(host=pushy_settings.get_redis_host())
    time.sleep(0.005)
    return rs.publish('%s%s' % (channel, key), json.dumps(message))