<commit_before>import re

class NULL: pass

RE_CACHE = {}

def plugin_get_url(obj):
    if getattr(obj, "page", None):
        title = obj.page.get_title_obj()
        if title:
            return title.path
    return None

def requires_load(meth):
    def _deco(self, *args, **kwargs):
        self.discover()<commit_msg>fixed ``plugin_get_url`` to work with multi site instances<commit_after>import re

from django.contrib.sites.models import Site

class NULL: pass

RE_CACHE = {}
SITE_CACHE = {}

def plugin_get_url(obj):

    if getattr(obj, "page", None):
        domain = '/'
        title = obj.page.get_title_obj()
        if title and title.path:
            if obj.page.site_id != Site.objects.get_current().pk:
                domain = 'http://%s/%s/' % (_get_domain_from_cache(obj.page.site_id), title.language)
            return domain + title.path
    return None

def _get_domain_from_cache(site_id):
    if not site_id in SITE_CACHE:
        SITE_CACHE[site_id] = Site.objects.get(pk=site_id).domain
    return SITE_CACHE[site_id]


def requires_load(meth):
    def _deco(self, *args, **kwargs):
        self.discover()
{'fraction_non_alphanumeric': 0.11961301671064203, 'fraction_numerical': 0.0, 'mean_word_length': 2.924137931034483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4579801', 'n_tokens_mistral': 386, 'n_tokens_neox': 379, 'n_words': 87}