API Documentation
Module
spoc
Elastic Frameworks
SPOC is a foundational framework designed to create dynamic and adaptable frameworks. It involves defining a schema for your project(s) and building upon that schema to create a flexible and powerful Application.
This module provides an example of how to create a framework by extending the spoc.Base class.
It demonstrates the initialization process using spoc.init with a list of modules,
and shows how to access and manage various components and plugins within the framework.
Example
To create a custom framework,
extend the spoc.Base class and initialize it using spoc.init with a list of desired modules:
from typing import Any
import spoc
MODULES = ["models", "views"]
class MyFramework(spoc.Base):
components: Any
plugins: Any
def init(self):
# __init__ Replacement
app = spoc.init(MODULES)
# Assign components and plugins from the initialized app
self.components = app.components
self.plugins = app.plugins
@staticmethod
def keys():
# Define a list of keys relevant to the framework
return ("components", "plugins")
Framework Tools
spoc.Base
A Singleton representing the entire class. Ensuring a single global point of access.
spoc.init(modules=None)
spoc.start_project(settings_text=SETTINGS_TEXT, spoc_text=SPOC_TEXT, env_text=ENV_TEXT)
Creates the core configuration files and directories for a project.
This function sets up the initial directory structure and creates the necessary
configuration files for a new project, including settings.py, spoc.toml,
and environment-specific configuration files.
Parameters:
-
settings_text(str, default:SETTINGS_TEXT) –The text content for the
settings.pyfile. -
spoc_text(str, default:SPOC_TEXT) –The text content for the
spoc.tomlfile. -
env_text(str, default:ENV_TEXT) –The text content for environment-specific
.tomlfiles (e.g.,production.toml,development.toml,staging.toml).
spoc.Components(*names)
Framework Components
A tool to manage the components.
Example: