예제 #1
0
 def setUp(self):
     # remove from registred configuration
     # configuration that we do no test in current test class
     REGISTRY.clear()
     for key, item in REGISTRY_COPY.iteritems():
         print key, item
         if key == self.tested_configuration_name:
             REGISTRY[key] = item
     self.clean_outbox()
예제 #2
0
 def setUp(self):
     # remove from registred configuration
     # configuration that we do no test in current test class
     REGISTRY.clear()
     for key, item in REGISTRY_COPY.iteritems():
         print key, item
         if key == self.tested_configuration_name:
             REGISTRY[key] = item
     self.clean_outbox()
예제 #3
0
def select(sender, instance=None, created=False, **kwargs):
    """Add instance to ItemToPush queue for each partner that
    validated the instance."""
    logger.debug(u'post_save caught for %s?pk=%s' %
                 (instance._meta.object_name, instance.pk))

    from carrier_pigeon.registry import REGISTRY

    for rule_name, configuration in REGISTRY.iteritems():
        if not SequentialPusherConfiguration in configuration.__class__.mro():
            # Only the sequential configurations are concerned here
            continue
        logger.debug('selecting Item for `%s` rule' % rule_name)
        # if instance doesn't match configuration
        # try another rule_name
        model_supervisor = None
        try:
            model_supervisor = configuration.get_supervisor_for_item(instance)
        except Exception:
            pass
        if (not model_supervisor
                or not filter(rule_name, model_supervisor, instance, created)):
            continue

        # try to create a row for each push_url
        add_item_to_push(instance, rule_name)
    logger.debug('end of select')
예제 #4
0
def select(sender, instance=None, created=False, **kwargs):
    """Add instance to ItemToPush queue for each partner that
    validated the instance."""
    logger.debug(u'post_save caught for %s?pk=%s' %
                 (instance._meta.object_name, instance.pk))

    from carrier_pigeon.registry import REGISTRY

    for rule_name, configuration in REGISTRY.iteritems():
        if not SequentialPusherConfiguration in configuration.__class__.mro():
            # Only the sequential configurations are concerned here
            continue
        logger.debug('selecting Item for `%s` rule' % rule_name)
        # if instance doesn't match configuration
        # try another rule_name
        model_supervisor = None
        try:
            model_supervisor = configuration.get_supervisor_for_item(instance)
        except Exception:
            pass
        if (not model_supervisor
            or not filter(rule_name, model_supervisor, instance, created)):
            continue

        # try to create a row for each push_url
        add_item_to_push(instance, rule_name)
    logger.debug('end of select')