Esempio n. 1
0
    def handle(self, *args, **options):
        if args:
            models = []
            for modelname in args:
                (modulename, classname) = modelname.rsplit(".", 1)
                module = __import__(modulename, fromlist=[classname])
                klass = getattr(module, classname)
                models.append(klass)
        else:
            models = get_indexed_models()

        for model in models:
            print("Reindexing %s instances" % model)
            for item in model.objects.all():
                print item.get_absolute_url()
                try:
                    aacore.signals.indexing_reindex_item(item)
                except RDF.RedlandError, e:
                    print "\tERROR,", e
            print
Esempio n. 2
0
def add_resource (url, rdf_model=RDF_MODEL, request=None, reload=False):
    """
    This is what gets called when in the aa browser you type a URL.
    """
    ## TODO: DEAL WITH URL NORMALIZATION HERE ?!
    ## actually need to peek ahead in models for tips on normalizing ...
    ## and actually, should a resource be created if no model claims the URL?

    (resource, created) = aacore.models.Resource.get_or_create_from_url(url, reload=reload)
    if created or reload:
        # relink delegates
        resource.delegates.all().delete()
        for model in get_indexed_models():
            if model == aacore.models.Resource:
                continue
            try:
                (delegate, created) = model.get_or_create_from_url(url, reload=reload)
                # are they already linked?
                if delegate:
                    resource_delegate = aacore.models.ResourceDelegate(resource=resource, delegate=delegate)
                    resource_delegate.save()
            except AttributeError:
                pass
        aacore.models.reindex_request.send(sender=resource.__class__, instance=resource)