🔍 Code Extractor

class FeatureDefinitionScope

Maturity: 42

An enumeration class that defines the scope levels for SharePoint Feature Definitions, representing the hierarchical levels at which a feature can be activated.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/features/definitions/scope.py
Lines:
1 - 14
Complexity:
simple

Purpose

This class serves as a constant enumeration to represent the different scope levels available for SharePoint Feature Definitions (SPFeatureDefinition). It provides integer constants that correspond to SharePoint's feature activation scopes: None (no scope), Farm (server farm level), Site (site collection level), and Web (individual web/subsite level). This is typically used when working with SharePoint features to specify or check at which level a feature should be activated or is currently active.

Source Code

class FeatureDefinitionScope:
    """Scope of the SPFeatureDefinition"""

    None_ = 0
    """Specifies no scope."""

    Farm = 1
    """Specifies farm scope."""

    Site = 2
    """Specifies site collection scope."""

    Web = 3
    """Specifies web scope."""

Parameters

Name Type Default Kind
bases - -

Parameter Details

bases: This class does not have an __init__ method and takes no initialization parameters. It is designed as a static enumeration class with class-level constants only.

Return Value

Instantiating this class returns a FeatureDefinitionScope object, though it is not intended to be instantiated. The class is designed to be used by accessing its class-level integer constants directly (e.g., FeatureDefinitionScope.Farm returns 1).

Class Interface

Attributes

Name Type Description Scope
None_ int Represents no scope (value: 0). Used when a feature has no specific scope defined. class
Farm int Represents farm scope (value: 1). Features at this level apply to the entire SharePoint server farm. class
Site int Represents site collection scope (value: 2). Features at this level apply to a specific site collection. class
Web int Represents web scope (value: 3). Features at this level apply to a specific web (subsite) within a site collection. class

Usage Example

# Access scope constants directly from the class
from feature_definition_scope import FeatureDefinitionScope

# Check if a feature scope is at farm level
feature_scope = FeatureDefinitionScope.Farm
if feature_scope == FeatureDefinitionScope.Farm:
    print("Feature is scoped at farm level")

# Use in a function to determine scope
def get_scope_name(scope_value):
    if scope_value == FeatureDefinitionScope.None_:
        return "No Scope"
    elif scope_value == FeatureDefinitionScope.Farm:
        return "Farm Scope"
    elif scope_value == FeatureDefinitionScope.Site:
        return "Site Collection Scope"
    elif scope_value == FeatureDefinitionScope.Web:
        return "Web Scope"
    return "Unknown"

print(get_scope_name(2))  # Output: Site Collection Scope

# Compare scope values
if FeatureDefinitionScope.Web > FeatureDefinitionScope.Site:
    print("Web scope is more specific than Site scope")

Best Practices

  • Do not instantiate this class; use it as a static enumeration by accessing class attributes directly
  • Use FeatureDefinitionScope.None_ (with underscore) instead of FeatureDefinitionScope.None to avoid Python keyword conflict
  • This class follows the pattern of a constant enumeration and should be treated as immutable
  • Consider using Python's enum.Enum or enum.IntEnum for more robust enumeration behavior in modern implementations
  • The integer values (0-3) represent increasing levels of specificity in SharePoint's hierarchy: Farm > Site > Web
  • When comparing scopes, remember that higher numeric values represent more granular/specific scopes

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class ViewScope 71.5% similar

    An enumeration-style class that defines constants for specifying the scope when retrieving items and folders in a SharePoint list view.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/views/scope.py
  • class FeatureDefinition 70.5% similar

    A class representing a SharePoint feature definition, containing metadata such as name, ID, scope, and version. Inherits from Entity base class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/features/definitions/definition.py
  • class PersonalizationScope 69.1% similar

    An enumeration class that defines personalization scope constants for the LimitedWebPartManager object in SharePoint Web Parts.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/webparts/personalization_scope.py
  • class FeatureDefinitionCollection 65.5% similar

    A collection class that manages and provides access to SharePoint feature definitions, extending EntityCollection to handle multiple FeatureDefinition objects.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/features/definitions/collection.py
  • class Feature 61.7% similar

    Represents an activated SharePoint feature with properties like definition ID and display name.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/features/feature.py
← Back to Browse