diff --git a/archivebox/builtin_plugins/singlefile/apps.py b/archivebox/builtin_plugins/singlefile/apps.py index 54e6cb2d..6fcc5051 100644 --- a/archivebox/builtin_plugins/singlefile/apps.py +++ b/archivebox/builtin_plugins/singlefile/apps.py @@ -20,7 +20,7 @@ from plugantic.base_hook import BaseHook # Depends on Other Plugins: from builtin_plugins.npm.apps import SYS_NPM_BINPROVIDER, LIB_NPM_BINPROVIDER - +from builtin_plugins.base.apps import CORE_CONFIG ###################### Config ########################## @@ -33,12 +33,11 @@ class SinglefileToggleConfigs(BaseConfigSet): class SinglefileOptionsConfigs(BaseConfigSet): section: ClassVar[ConfigSectionName] = 'ARCHIVE_METHOD_OPTIONS' - # loaded from shared config - SINGLEFILE_USER_AGENT: str = Field(default='', alias='USER_AGENT') - SINGLEFILE_TIMEOUT: int = Field(default=60, alias='TIMEOUT') - SINGLEFILE_CHECK_SSL_VALIDITY: bool = Field(default=True, alias='CHECK_SSL_VALIDITY') - SINGLEFILE_RESTRICT_FILE_NAMES: str = Field(default='windows', alias='RESTRICT_FILE_NAMES') - SINGLEFILE_COOKIES_FILE: Optional[Path] = Field(default=None, alias='COOKIES_FILE') + SINGLEFILE_USER_AGENT: str = Field(default=lambda: CORE_CONFIG.USER_AGENT) + SINGLEFILE_TIMEOUT: int = Field(default=lambda: CORE_CONFIG.TIMEOUT) + SINGLEFILE_CHECK_SSL_VALIDITY: bool = Field(default=lambda: CORE_CONFIG.CHECK_SSL_VALIDITY) + SINGLEFILE_RESTRICT_FILE_NAMES: str = Field(default=lambda: CORE_CONFIG.RESTRICT_FILE_NAMES) + SINGLEFILE_COOKIES_FILE: Optional[Path] = Field(default=lambda: CORE_CONFIG.COOKIES_FILE) class SinglefileDependencyConfigs(BaseConfigSet): diff --git a/archivebox/plugantic/base_configset.py b/archivebox/plugantic/base_configset.py index f1631886..09d6fbfa 100644 --- a/archivebox/plugantic/base_configset.py +++ b/archivebox/plugantic/base_configset.py @@ -201,18 +201,21 @@ class BaseConfigSet(ArchiveBoxBaseConfig, BaseHook): # type: ignore[type-ar def register(self, settings, parent_plugin=None): # self._plugin = parent_plugin # for debugging only, never rely on this! - settings.FLAT_CONFIG = getattr(settings, "FLAT_CONFIG", None) or benedict({}) + # settings.FLAT_CONFIG = benedict(getattr(settings, "FLAT_CONFIG", settings.CONFIG)) + # # pass FLAT_CONFIG so far into our config model to load it + # loaded_config = self.__class__(**settings.FLAT_CONFIG) + # # then dump our parsed config back into FLAT_CONFIG for the next plugin to use + # settings.FLAT_CONFIG.merge(loaded_config.model_dump(include=set(self.model_fields.keys()))) + settings.CONFIGS = getattr(settings, "CONFIGS", None) or benedict({}) - - # pass FLAT_CONFIG so far into our config model to load it - loaded_config = self.__class__(**settings.FLAT_CONFIG) - # then dump our parsed config back into FLAT_CONFIG for the next plugin to use - settings.FLAT_CONFIG.merge(loaded_config.model_dump()) - - settings.CONFIGS[self.id] = loaded_config + settings.CONFIGS[self.id] = self + self._original_id = id(self) super().register(settings, parent_plugin=parent_plugin) + # def ready(self, settings): + # # reload config from environment, in case it's been changed by any other plugins + # self.__init__() # class WgetToggleConfig(ConfigSet):