<commit_before>"""Page management utilities."""

import abc

from django.conf import settings

from cms.core.loader import load_object
from cms.core.optimizations import cached_getter


class BackendBase(object):
    
    """Base class for a page backend implementation."""
    
    __metaclass__ = abc.ABCMeta
    
    # The primary model of the backend.
    model = None
    
    @abc.abstractmethod
    def get_homepage(self, request):
        """Returns the current homepage, or None."""
        raise NotImplementedError
    
    @abc.abstractmethod    
    def get_current(self, request):
        """Returns the current best-matched page, or None."""
        raise NotImplementedError
    
    def get(self, request, id):
        """Returns the page matching the given id, or None."""
        return self.model._default_manager.get(pd=id)
        
    @abc.abstractmethod
    def reverse(self, request, page, view_name, args, kwargs):
        """Reverses the given url in the context of the given page."""
        raise NotImplementedError
    
    # Navigation.
    
    def get_navigation(self, request, level):
        """Returns the navigation list for the given level (zero-indexed)."""
        page = self.get_current(request)
        section = page.breadcrumbs[level]
        return section.navigation
    
    # Does this backend support moving pages around?    
    can_move = False
    
    def move_up(self, request, page):<commit_msg>Fix for missing secondary navigation<commit_after>"""Page management utilities."""

import abc

from django.conf import settings

from cms.core.loader import load_object
from cms.core.optimizations import cached_getter


class BackendBase(object):
    
    """Base class for a page backend implementation."""
    
    __metaclass__ = abc.ABCMeta
    
    # The primary model of the backend.
    model = None
    
    @abc.abstractmethod
    def get_homepage(self, request):
        """Returns the current homepage, or None."""
        raise NotImplementedError
    
    @abc.abstractmethod    
    def get_current(self, request):
        """Returns the current best-matched page, or None."""
        raise NotImplementedError
    
    def get(self, request, id):
        """Returns the page matching the given id, or None."""
        return self.model._default_manager.get(pd=id)
        
    @abc.abstractmethod
    def reverse(self, request, page, view_name, args, kwargs):
        """Reverses the given url in the context of the given page."""
        raise NotImplementedError
    
    # Navigation.
    
    def get_navigation(self, request, level):
        """Returns the navigation list for the given level (zero-indexed)."""
        page = self.get_current(request)
        try:
            section = page.breadcrumbs[level]
        except IndexError:
            return []
        else:
            return section.navigation
    
    # Does this backend support moving pages around?    
    can_move = False
    
    def move_up(self, request, page):
{'fraction_non_alphanumeric': 0.087346396545998, 'fraction_numerical': 0.0, 'mean_word_length': 2.5644970414201183, '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': '5750664', 'n_tokens_mistral': 805, 'n_tokens_neox': 808, 'n_words': 268}