# Path: oembed/models.py
# class StoredProvider(models.Model, HTTPProvider):
#     """
#     Essentially, a stored proxy provider that mimics the interface of a python
#     HTTPProvider - used for autodiscovery
#     """
#     endpoint_url = models.CharField(max_length=255)
#     regex = models.CharField(max_length=255)
#     wildcard_regex = models.CharField(max_length=255, blank=True,
#         help_text='Wild-card version of regex')
#     resource_type = models.CharField(choices=RESOURCE_CHOICES, max_length=8)
#     active = models.BooleanField(default=False)
#     provides = models.BooleanField(default=False, help_text='Provide upstream')
#     scheme_url = models.CharField(max_length=255, blank=True)
# 
#     objects = StoredProviderManager()
# 
#     class Meta:
#         ordering = ('endpoint_url', 'resource_type', 'wildcard_regex')
# 
#     def __unicode__(self):
#         return self.wildcard_regex
# 
#     def save(self, *args, **kwargs):
#         if not self.regex:
#             # convert wildcard to non-greedy 'match anything' regex
#             self.regex = self.wildcard_regex.replace('*', '.+?')
#         super(StoredProvider, self).save(*args, **kwargs)
# 
#     @property
#     def url_scheme(self):
#         if self.provides and self.wildcard_regex:
#             return self.wildcard_regex


from django.db.models.signals import post_save
from oembed.models import StoredProvider
import oembed


def provider_site_invalidate(sender, instance, created, **kwargs):
    oembed.site.invalidate_providers()

def start_listening():

# Path: oembed/models.py
# class StoredProvider(models.Model, HTTPProvider):
#     """
#     Essentially, a stored proxy provider that mimics the interface of a python
#     HTTPProvider - used for autodiscovery
#     """
#     endpoint_url = models.CharField(max_length=255)
#     regex = models.CharField(max_length=255)
#     wildcard_regex = models.CharField(max_length=255, blank=True,
#         help_text='Wild-card version of regex')
#     resource_type = models.CharField(choices=RESOURCE_CHOICES, max_length=8)
#     active = models.BooleanField(default=False)
#     provides = models.BooleanField(default=False, help_text='Provide upstream')
#     scheme_url = models.CharField(max_length=255, blank=True)
# 
#     objects = StoredProviderManager()
# 
#     class Meta:
#         ordering = ('endpoint_url', 'resource_type', 'wildcard_regex')
# 
#     def __unicode__(self):
#         return self.wildcard_regex
# 
#     def save(self, *args, **kwargs):
#         if not self.regex:
#             # convert wildcard to non-greedy 'match anything' regex
#             self.regex = self.wildcard_regex.replace('*', '.+?')
#         super(StoredProvider, self).save(*args, **kwargs)
# 
#     @property
#     def url_scheme(self):
#         if self.provides and self.wildcard_regex:
#             return self.wildcard_regex


# Path: oembed/listeners.py
from django.db.models.signals import post_save
from oembed.models import StoredProvider
import oembed



def provider_site_invalidate(sender, instance, created, **kwargs):
    oembed.site.invalidate_providers()

def start_listening():

    post_save.connect(provider_site_invalidate, sender=StoredProvider)