Exemplo n.º 1
0
 def __init__(self, skip_internal=False):
     self.skip_internal = skip_internal
     registry.ensure_populated()
Exemplo n.º 2
0
    def __unicode__(self):
        return self.scheme


def _update_provider(sender, instance, created, **kwargs):
    """Post-save signal callback"""
    instance.invalidate_scheme_cache()
    registry.update(instance)


def _unregister_provider(sender, instance, **kwargs):
    """Post-delete signal callback"""
    registry.unregister(instance)


def _invalidate_provider_schemes(sender, instance, created, **kwargs):
    # Invalidate the related object cache
    instance.provider.invalidate_scheme_cache()


# Connect signals
models.signals.post_save.connect(_update_provider, sender=ThirdPartyProvider)
models.signals.post_save.connect(_invalidate_provider_schemes, sender=URLScheme)

models.signals.post_delete.connect(_unregister_provider, sender=ThirdPartyProvider)


# Prepopulate
registry.ensure_populated()