def template(self):
        # Check for the magical "index" added by the browser:page template
        # machinery. If it exists this is actually the
        # zope.browserpage.simpleviewclass.simple class that is magically
        # mixed in by the browser:page zcml directive the template defined in
        # the directive should be used.
        if safe_hasattr(self, 'index'):
            return super(HasSpecificationsView, self).template

        # Sprints and Persons don't have a usage enum for blueprints, so we
        # have to fallback to the default.
        if (ISprint.providedBy(self.context)
                or IPerson.providedBy(self.context)):
            return self.default_template

        # ProjectGroups are a special case, as their products may be a
        # combination of usage settings. To deal with this, check all
        # products via the involvment menu.
        if (IProjectGroup.providedBy(self.context)
                or IProjectGroupSeries.providedBy(self.context)):
            involvement = getMultiAdapter((self.context, self.request),
                                          name='+get-involved')
            if service_uses_launchpad(involvement.blueprints_usage):
                return self.default_template
            else:
                return self.not_launchpad_template

        # Otherwise, determine usage and provide the correct template.
        service_usage = IServiceUsage(self.context)
        if service_uses_launchpad(service_usage.blueprints_usage):
            return self.default_template
        else:
            return self.not_launchpad_template
    def template(self):
        # Check for the magical "index" added by the browser:page template
        # machinery. If it exists this is actually the
        # zope.browserpage.simpleviewclass.simple class that is magically
        # mixed in by the browser:page zcml directive the template defined in
        # the directive should be used.
        if safe_hasattr(self, 'index'):
            return super(HasSpecificationsView, self).template

        # Sprints and Persons don't have a usage enum for blueprints, so we
        # have to fallback to the default.
        if (ISprint.providedBy(self.context)
            or IPerson.providedBy(self.context)):
            return self.default_template

        # ProjectGroups are a special case, as their products may be a
        # combination of usage settings. To deal with this, check all
        # products via the involvment menu.
        if (IProjectGroup.providedBy(self.context)
            or IProjectGroupSeries.providedBy(self.context)):
            involvement = getMultiAdapter(
                (self.context, self.request),
                name='+get-involved')
            if service_uses_launchpad(involvement.blueprints_usage):
                return self.default_template
            else:
                return self.not_launchpad_template

        # Otherwise, determine usage and provide the correct template.
        service_usage = IServiceUsage(self.context)
        if service_uses_launchpad(service_usage.blueprints_usage):
            return self.default_template
        else:
            return self.not_launchpad_template
    def _getByName(self, name):
        """Finds a specification by name from the current context.

        Returns a specification if (and only if) the current context
        defines a unique specification namespace and then if a matching
        specification can be found within that namespace. Returns None
        otherwise.
        """
        if ISpecificationSet.providedBy(self.context):
            # The context is the set of all specifications. Since this
            # set corresponds to multiple specification namespaces, we
            # return None.
            return None
        elif IProjectGroup.providedBy(self.context):
            # The context is a project group. Since a project group
            # corresponds to multiple specification namespaces, we
            # return None.
            return None
        elif ISpecification.providedBy(self.context):
            # The context is a specification. Since a specification's
            # target defines a single specification namespace, we ask
            # the target to perform the lookup.
            return self.context.target.getSpecification(name)
        elif ISprint.providedBy(self.context):
            # The context is a sprint. Since a sprint corresponds
            # to multiple specification namespaces, we return None.
            return None
        else:
            # The context is a entity such as a product or distribution.
            # Since this type of context is associated with exactly one
            # specification namespace, we ask the context to perform the
            # lookup.
            return self.context.getSpecification(name)
    def _getByName(self, name):
        """Finds a specification by name from the current context.

        Returns a specification if (and only if) the current context
        defines a unique specification namespace and then if a matching
        specification can be found within that namespace. Returns None
        otherwise.
        """
        if ISpecificationSet.providedBy(self.context):
            # The context is the set of all specifications. Since this
            # set corresponds to multiple specification namespaces, we
            # return None.
            return None
        elif IProjectGroup.providedBy(self.context):
            # The context is a project group. Since a project group
            # corresponds to multiple specification namespaces, we
            # return None.
            return None
        elif ISpecification.providedBy(self.context):
            # The context is a specification. Since a specification's
            # target defines a single specification namespace, we ask
            # the target to perform the lookup.
            return self.context.target.getSpecification(name)
        elif ISprint.providedBy(self.context):
            # The context is a sprint. Since a sprint corresponds
            # to multiple specification namespaces, we return None.
            return None
        else:
            # The context is a entity such as a product or distribution.
            # Since this type of context is associated with exactly one
            # specification namespace, we ask the context to perform the
            # lookup.
            return self.context.getSpecification(name)
    def initialize(self):
        if IPerson.providedBy(self.context):
            self.is_person = True
        elif IDistribution.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.show_series = True
        elif IProduct.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_series = True
        elif IProjectGroup.providedBy(self.context):
            self.is_project = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_target = True
            self.show_series = True
        elif IProjectGroupSeries.providedBy(self.context):
            self.show_milestone = True
            self.show_target = True
            self.show_series = True
        elif (IProductSeries.providedBy(self.context) or
              IDistroSeries.providedBy(self.context)):
            self.is_series = True
            self.show_milestone = True
        elif ISprint.providedBy(self.context):
            self.is_sprint = True
            self.show_target = True
        else:
            raise AssertionError('Unknown blueprint listing site.')

        if IHasDrivers.providedBy(self.context):
            self.has_drivers = True

        self.batchnav = BatchNavigator(
            self.specs, self.request,
            size=config.launchpad.default_batch_size)
    def initialize(self):
        if IPerson.providedBy(self.context):
            self.is_person = True
        elif IDistribution.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.show_series = True
        elif IProduct.providedBy(self.context):
            self.is_target = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_series = True
        elif IProjectGroup.providedBy(self.context):
            self.is_project = True
            self.is_pillar = True
            self.has_wiki = True
            self.show_target = True
            self.show_series = True
        elif IProjectGroupSeries.providedBy(self.context):
            self.show_milestone = True
            self.show_target = True
            self.show_series = True
        elif (IProductSeries.providedBy(self.context)
              or IDistroSeries.providedBy(self.context)):
            self.is_series = True
            self.show_milestone = True
        elif ISprint.providedBy(self.context):
            self.is_sprint = True
            self.show_target = True
        else:
            raise AssertionError('Unknown blueprint listing site.')

        if IHasDrivers.providedBy(self.context):
            self.has_drivers = True

        self.batchnav = BatchNavigator(
            self.specs, self.request, size=config.launchpad.default_batch_size)