-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.example.py
More file actions
102 lines (77 loc) · 5.03 KB
/
config.example.py
File metadata and controls
102 lines (77 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# SPDX-FileCopyrightText: 2025 Arcangelo Massari <arcangelo.massari@unibo.it>
#
# SPDX-License-Identifier: ISC
import os
from heritrace.utils.strategies import OrphanHandlingStrategy, ProxyHandlingStrategy
BASE_HERITRACE_DIR = os.path.abspath(os.path.dirname(__file__))
def _load_class(class_path: str):
"""Dynamically load a class from a module path."""
module_path, class_name = class_path.rsplit('.', 1)
module = __import__(module_path, fromlist=[class_name])
return getattr(module, class_name)
counter_handler_class_path = os.environ.get('COUNTER_HANDLER_CLASS', 'default_components.meta_counter_handler.MetaCounterHandler')
uri_generator_class_path = os.environ.get('URI_GENERATOR_CLASS', 'default_components.meta_uri_generator.MetaURIGenerator')
counter_handler_class = _load_class(counter_handler_class_path)
uri_generator_class = _load_class(uri_generator_class_path)
counter_handler = counter_handler_class()
meta_uri_generator = uri_generator_class(counter_handler)
shacl_path = os.path.join(BASE_HERITRACE_DIR, "shacl.ttl")
display_rules_path = os.path.join(BASE_HERITRACE_DIR, "display_rules.yaml")
class Config(object):
APP_TITLE = os.environ.get("APP_TITLE", "HERITRACE")
APP_SUBTITLE = os.environ.get("APP_SUBTITLE", "Heritage Enhanced Repository Interface")
SECRET_KEY = os.environ.get("SECRET_KEY", "generate-a-secure-random-key")
CACHE_VALIDITY_DAYS = int(os.environ.get("CACHE_VALIDITY_DAYS", "7"))
# Redis Configuration
# If REDIS_URL is not set, the application uses an internal Redis instance
REDIS_URL = os.environ.get("REDIS_URL")
# Query Configuration
# COUNT_LIMIT serves dual purpose:
# 1. Maximum entity count to display (shows "10000+" if exceeded)
# 2. Threshold for automatic cache refresh after entity modifications
# - Datasets below this limit: auto-refresh enabled (always accurate counts)
# - Datasets above this limit: cache remains static (manual refresh via admin endpoint)
COUNT_LIMIT = int(os.environ.get("COUNT_LIMIT", "10000"))
# Database configuration
DATASET_DB_TRIPLESTORE = os.environ.get("DATASET_DB_TRIPLESTORE", "virtuoso") # Options: 'virtuoso' or 'blazegraph'
DATASET_DB_TEXT_INDEX_ENABLED = os.environ.get("DATASET_DB_TEXT_INDEX_ENABLED", "true").lower() == "true"
PROVENANCE_DB_TRIPLESTORE = os.environ.get("PROVENANCE_DB_TRIPLESTORE", "virtuoso")
# Database endpoints
DATASET_DB_URL = os.environ.get("DATASET_DB_URL", "http://localhost:8999/sparql")
PROVENANCE_DB_URL = os.environ.get("PROVENANCE_DB_URL", "http://localhost:8998/sparql")
# Database store types
DATASET_IS_QUADSTORE = os.environ.get("DATASET_IS_QUADSTORE", "true").lower() == "true"
PROVENANCE_IS_QUADSTORE = os.environ.get("PROVENANCE_IS_QUADSTORE", "true").lower() == "true"
DATASET_GENERATION_TIME = os.environ.get("DATASET_GENERATION_TIME", "2024-12-25T00:00:00+00:00")
URI_GENERATOR = meta_uri_generator
COUNTER_HANDLER = counter_handler
# Internationalization
LANGUAGES = ["en", "it"]
BABEL_TRANSLATION_DIRECTORIES = os.path.join(
BASE_HERITRACE_DIR, "babel", "translations"
)
CHANGE_TRACKING_CONFIG = os.path.join(BASE_HERITRACE_DIR, "change_tracking.json")
PRIMARY_SOURCE = os.environ.get("PRIMARY_SOURCE", "https://doi.org/your-doi")
SHACL_PATH = shacl_path
DISPLAY_RULES_PATH = display_rules_path
# ORCID Integration
# Get these values from https://orcid.org/developer-tools
ORCID_CLIENT_ID = os.environ.get("ORCID_CLIENT_ID", "your-client-id")
ORCID_CLIENT_SECRET = os.environ.get("ORCID_CLIENT_SECRET", "your-client-secret")
ORCID_AUTHORIZE_URL = os.environ.get("ORCID_AUTHORIZE_URL", "https://orcid.org/oauth/authorize")
ORCID_TOKEN_URL = os.environ.get("ORCID_TOKEN_URL", "https://orcid.org/oauth/token")
ORCID_API_URL = os.environ.get("ORCID_API_URL", "https://pub.orcid.org/v2.1")
ORCID_SCOPE = os.environ.get("ORCID_SCOPE", "/authenticate")
# Parse ORCID safelist from environment (comma-separated)
_orcid_safelist_str = os.environ.get("ORCID_SAFELIST", "your-allowed-orcid-1,your-allowed-orcid-2")
ORCID_SAFELIST = [orcid.strip() for orcid in _orcid_safelist_str.split(",") if orcid.strip()]
# Entity handling configuration - strategies can be configured via environment variables
# Available options: ASK, DELETE, KEEP
_orphan_strategy_str = os.environ.get("ORPHAN_HANDLING_STRATEGY", "ASK").upper()
ORPHAN_HANDLING_STRATEGY = getattr(OrphanHandlingStrategy, _orphan_strategy_str, OrphanHandlingStrategy.ASK)
_proxy_strategy_str = os.environ.get("PROXY_HANDLING_STRATEGY", "DELETE").upper()
PROXY_HANDLING_STRATEGY = getattr(ProxyHandlingStrategy, _proxy_strategy_str, ProxyHandlingStrategy.DELETE)
# Catalogue pagination configuration
CATALOGUE_DEFAULT_PER_PAGE = int(os.environ.get("CATALOGUE_DEFAULT_PER_PAGE", "50"))
_catalogue_allowed_per_page_str = os.environ.get("CATALOGUE_ALLOWED_PER_PAGE", "50,100,200,500")
CATALOGUE_ALLOWED_PER_PAGE = [int(x.strip()) for x in _catalogue_allowed_per_page_str.split(",") if x.strip()]