function get_integration_status
Retrieves the integration status of the DocChat blueprint within a Flask application, including registration status, configuration details, and dependency checks.
/tf/active/vicechatdev/docchat/integration.py
156 - 183
simple
Purpose
This function is used to diagnose and verify the DocChat integration in a Flask application. It checks whether the 'docchat' blueprint is properly registered, retrieves its configuration settings (URL prefix, static folder, template folder), and validates dependencies. This is useful for debugging integration issues, health checks, and ensuring the DocChat feature is correctly set up before use.
Source Code
def get_integration_status(app):
"""
Get status of DocChat integration.
Args:
app: Flask application instance
Returns:
dict: Integration status information
"""
status = {
'registered': False,
'dependencies': None,
'config': {}
}
# Check if blueprint is registered
if 'docchat' in app.blueprints:
status['registered'] = True
bp = app.blueprints['docchat']
status['config']['url_prefix'] = bp.url_prefix
status['config']['static_folder'] = bp.static_folder
status['config']['template_folder'] = bp.template_folder
# Check dependencies
status['dependencies'] = check_dependencies(app)
return status
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
app |
- | - | positional_or_keyword |
Parameter Details
app: A Flask application instance. This should be the main Flask app object where blueprints are registered. The function will inspect this app's blueprints dictionary to check for the 'docchat' blueprint and call check_dependencies with this app instance.
Return Value
Returns a dictionary with three keys: 'registered' (boolean indicating if the 'docchat' blueprint is registered in the Flask app), 'dependencies' (result from check_dependencies function, type depends on that function's implementation), and 'config' (dictionary containing blueprint configuration with keys 'url_prefix', 'static_folder', and 'template_folder' if registered, empty dict otherwise).
Dependencies
flask
Required Imports
from flask import Flask
from blueprint import docchat_bp
from config import config as docchat_config
Usage Example
from flask import Flask
from your_module import get_integration_status
app = Flask(__name__)
# Optionally register the docchat blueprint
# from blueprint import docchat_bp
# app.register_blueprint(docchat_bp, url_prefix='/docchat')
status = get_integration_status(app)
print(f"DocChat registered: {status['registered']}")
if status['registered']:
print(f"URL prefix: {status['config']['url_prefix']}")
print(f"Static folder: {status['config']['static_folder']}")
print(f"Template folder: {status['config']['template_folder']}")
print(f"Dependencies: {status['dependencies']}")
Best Practices
- Call this function after all blueprints have been registered to get accurate status
- Use this function in health check endpoints or startup validation routines
- Ensure the check_dependencies function is properly implemented before using this function
- The function assumes the blueprint name is exactly 'docchat' - ensure consistency in blueprint naming
- Consider logging the status information for debugging purposes in production environments
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function integrate_docchat 78.9% similar
-
function check_dependencies 73.8% similar
-
function register_docchat 69.3% similar
-
function system_status 56.8% similar
-
function configure_docchat 55.8% similar