コード例 #1
0
 def load(self):
     artifact_orm_session._get().skip_mod_date = True
     self.load_pages()
     self.project.notifications_disabled = False
     artifact_orm_session._get().skip_mod_date = False
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     allura_base.log.info('Loading wiki done')
コード例 #2
0
ファイル: loaders.py プロジェクト: Bitergia/allura
 def load(self):
     artifact_orm_session._get().skip_mod_date = True
     self.load_pages()
     self.project.notifications_disabled = False
     artifact_orm_session._get().skip_mod_date = False
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     allura_base.log.info('Loading wiki done')
コード例 #3
0
 def load(self):
     try:
         self.project.notifications_disabled = True
         artifact_orm_session._get().skip_mod_date = True
         self.load_pages()
         ThreadLocalORMSession.flush_all()
         log.info('Loading wiki done')
     finally:
         self.project.notifications_disabled = False
         artifact_orm_session._get().skip_mod_date = False
コード例 #4
0
 def load(self):
     try:
         self.project.notifications_disabled = True
         artifact_orm_session._get().skip_mod_date = True
         self.load_pages()
         ThreadLocalORMSession.flush_all()
         log.info('Loading wiki done')
     finally:
         self.project.notifications_disabled = False
         artifact_orm_session._get().skip_mod_date = False
コード例 #5
0
ファイル: app_globals.py プロジェクト: githubcodi/allura
    def cached_convert(self, artifact, field_name):
        """Convert ``artifact.field_name`` markdown source to html, caching
        the result if the render time is greater than the defined threshold.

        """
        source_text = getattr(artifact, field_name)
        # Check if contents macro and never cache
        if "[[" in source_text:
            return self.convert(source_text)
        cache_field_name = field_name + '_cache'
        cache = getattr(artifact, cache_field_name, None)
        if not cache:
            log.warn(
                'Skipping Markdown caching - Missing cache field "%s" on class %s',
                field_name, artifact.__class__.__name__)
            return self.convert(source_text)

        bugfix_rev = 3  # increment this if we need all caches to invalidated (e.g. xss in markdown rendering fixed)
        md5 = None
        # If a cached version exists and it is valid, return it.
        if cache.md5 is not None:
            md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
            if cache.md5 == md5 and getattr(cache, 'fix7528',
                                            False) == bugfix_rev:
                return h.html.literal(cache.html)

        # Convert the markdown and time the result.
        start = time.time()
        html = self.convert(source_text, render_limit=False)
        render_time = time.time() - start

        threshold = config.get('markdown_cache_threshold')
        try:
            threshold = float(threshold) if threshold else None
        except ValueError:
            threshold = None
            log.warn('Skipping Markdown caching - The value for config param '
                     '"markdown_cache_threshold" must be a float.')

        if threshold is not None and render_time > threshold:
            # Save the cache
            if md5 is None:
                md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
            cache.md5, cache.html, cache.render_time = md5, html, render_time
            cache.fix7528 = bugfix_rev  # flag to indicate good caches created after [#7528] and other critical bugs were fixed.

            # Prevent cache creation from updating the mod_date timestamp.
            _session = artifact_orm_session._get()
            _session.skip_mod_date = True
        return html
コード例 #6
0
ファイル: app_globals.py プロジェクト: heiths/allura
    def cached_convert(self, artifact, field_name):
        """Convert ``artifact.field_name`` markdown source to html, caching
        the result if the render time is greater than the defined threshold.

        """
        source_text = getattr(artifact, field_name)
        # Check if contents macro and never cache
        if "[[" in source_text:
            return self.convert(source_text)
        cache_field_name = field_name + '_cache'
        cache = getattr(artifact, cache_field_name, None)
        if not cache:
            log.warn(
                'Skipping Markdown caching - Missing cache field "%s" on class %s',
                field_name, artifact.__class__.__name__)
            return self.convert(source_text)

        bugfix_rev = 2  # increment this if we need all caches to invalidated (e.g. xss in markdown rendering fixed)
        md5 = None
        # If a cached version exists and it is valid, return it.
        if cache.md5 is not None:
            md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
            if cache.md5 == md5 and getattr(cache, 'fix7528', False) == bugfix_rev:
                return h.html.literal(cache.html)

        # Convert the markdown and time the result.
        start = time.time()
        html = self.convert(source_text, render_limit=False)
        render_time = time.time() - start

        threshold = config.get('markdown_cache_threshold')
        try:
            threshold = float(threshold) if threshold else None
        except ValueError:
            threshold = None
            log.warn('Skipping Markdown caching - The value for config param '
                     '"markdown_cache_threshold" must be a float.')

        if threshold is not None and render_time > threshold:
            # Save the cache
            if md5 is None:
                md5 = hashlib.md5(source_text.encode('utf-8')).hexdigest()
            cache.md5, cache.html, cache.render_time = md5, html, render_time
            cache.fix7528 = bugfix_rev  # flag to indicate good caches created after [#7528] and other critical bugs were fixed.

            # Prevent cache creation from updating the mod_date timestamp.
            _session = artifact_orm_session._get()
            _session.skip_mod_date = True
        return html