Exemple #1
0
def find_all_links(all_linklists):
    all_links_dict = {}
    Url.objects.all().update(still_exists=False)
    for linklist_name, linklist_cls in all_linklists.items():
        content_type = linklist_cls.content_type()
        linklists = linklist_cls().get_linklist()
        for linklist in linklists:
            object_id = linklist['object'].id
            urls = linklist['urls']+linklist['images']
            if urls:
                update_urls(urls, content_type, object_id)
        all_links_dict[linklist_name] = linklists
    Url.objects.filter(still_exists=False).delete()
Exemple #2
0
def find_all_links(all_linklists):
    all_links_dict = {}
    Url.objects.all().update(still_exists=False)
    for linklist_name, linklist_cls in all_linklists.items():
        content_type = linklist_cls.content_type()
        linklists = linklist_cls().get_linklist()
        for linklist in linklists:
            object_id = linklist['object'].id
            urls = linklist['urls'] + linklist['images']
            if urls:
                update_urls(urls, content_type, object_id)
        all_links_dict[linklist_name] = linklists
    Url.objects.filter(still_exists=False).delete()
    from filebrowser.views import filebrowser_post_upload
    from filebrowser.views import filebrowser_post_rename
    from filebrowser.views import filebrowser_post_delete
    from filebrowser.settings import DIRECTORY
    FILEBROWSER_PRESENT = True
except ImportError:
    FILEBROWSER_PRESENT = False

from linkcheck.models import all_linklists, Url, Link

listeners = []
# a global variable, showing whether linkcheck is still working
still_updating = False

#1, register listeners for the objects that contain Links
for linklist_name, linklist_cls in all_linklists.items():
    
    def check_instance_links(sender, instance, linklist_cls=linklist_cls, **kwargs):
        '''
        When an object is saved:
            new Link/Urls are created, checked
        When an object is modified:
            new Link/Urls are created, checked
            existing Link/Urls are checked
            disappering Links are deleted
        '''
        def do_check_instance_links(sender, instance, linklist_cls=linklist_cls):

            try:
                still_updating = True
                content_type = linklist_cls.content_type()
Exemple #4
0
    from filebrowser.views import filebrowser_post_delete
    from filebrowser.settings import DIRECTORY
    FILEBROWSER_PRESENT = True
except ImportError:
    FILEBROWSER_PRESENT = False


from . import update_lock
from linkcheck.models import all_linklists, Url, Link

listeners = []


# 1. register listeners for the objects that contain Links

for linklist_name, linklist_cls in all_linklists.items():

    def check_instance_links(sender, instance, linklist_cls=linklist_cls, **kwargs):
        """
        When an object is saved:
            new Link/Urls are created, checked

        When an object is modified:
            new link/urls are created, checked
            existing link/urls are checked
            Removed links are deleted
        """

        def do_check_instance_links(sender, instance, linklist_cls=linklist_cls, wait=False):
            # On some installations, this wait time might be enough for the
            # thread transaction to account for the object change (GH #41).
Exemple #5
0
def is_model_covered(klass):
    for linklist in all_linklists.items():
        if linklist[1].model == klass:
            return True
    return False
Exemple #6
0
def is_model_covered(klass):
    for linklist in all_linklists.items():
        if linklist[1].model == klass:
            return True
    return False