示例#1
0
def register_signals():
    for metadata_class in registry.values():
        model_instance = metadata_class._meta.get_model('modelinstance')
        if model_instance is not None:
            update_callback = curry(_update_callback,
                                    model_class=model_instance)
            delete_callback = curry(_delete_callback,
                                    model_class=model_instance)

            ## Connect the models listed in settings to the update callback.
            for model in metadata_class._meta.seo_models:
                # TODO Currently it's not needed to create metadata for new instance
                models.signals.post_save.connect(update_callback,
                                                 sender=model,
                                                 weak=False)
                models.signals.pre_delete.connect(delete_callback,
                                                  sender=model,
                                                  weak=False)

    if getattr(settings, 'SEO_USE_REDIRECTS', False):
        redirects_models = import_tracked_models()
        for model in redirects_models:
            redirects_callback = curry(_handle_redirects_callback,
                                       model_class=model_instance)
            models.signals.pre_save.connect(redirects_callback,
                                            sender=model,
                                            weak=False)
示例#2
0
def register_signals():
    for metadata_class in registry.values():
        model_instance = metadata_class._meta.get_model('modelinstance')
        if model_instance is not None:
            update_callback = curry(_update_callback, model_class=model_instance)
            delete_callback = curry(_delete_callback, model_class=model_instance)

            ## Connect the models listed in settings to the update callback.
            for model in metadata_class._meta.seo_models:
                # TODO Currently it's not needed to create metadata for new instance
                models.signals.post_save.connect(update_callback, sender=model, weak=False)
                models.signals.pre_delete.connect(delete_callback, sender=model, weak=False)

    if getattr(settings, 'SEO_USE_REDIRECTS', False):
        redirects_models = import_tracked_models()
        for model in redirects_models:
            redirects_callback = curry(_handle_redirects_callback, model_class=model_instance)
            models.signals.pre_save.connect(redirects_callback, sender=model, weak=False)