The Config Module (tendril.utils.config)

This module provides the core configuration for Tendril.

The Tendril configuration file is itself a Python file, and is imported from it’s default location (INSTANCE_ROOT/instance_config.py, where INSTANCE_ROOT is ~/.tendril). In case this folder needs to be moved elsewhere, such as when it needs to be run via wsgi using the web server’s user, the INSTANCE_ROOT can be moved by placing a file in the user’s home directory (~/.tendril/redirect), containing the path to the actual instance folder.

The instance_config.py file is the primary configuration for Tendril. It is intended to be maintained at an Instance level by the tendril administrator. Since some parameters may need to be changed per-installation to adapt it to the user’s setup, an additional configuration file can be added in (INSTANCE_ROOT/local_config_overrides.py), containing only those parameters which the user wishes to override.

When the configuration is parsed during startup, (at the time of the first import of the config module) this module performs the import using the tendril.utils.fsutils.import_() function and the imp module. Each recognized config option and variable is obtained from the first location where it is found from the following list of sources:

  • local_config_overrides.py
  • instance_config.py
  • The defaults specified here.

The following constraints should be kept in mind when setting up your configuration :

  • The configuration files are all python files. You can execute pretty much whatever you want within them, as long as the final configuration value ends up in the module namespace at the correct variable.
  • The order of the config parameters is somewhat important. The actual configuration values can be constructed at run time from configurations parameters which already exist in the namespace.
  • The core config module (this one) uses eval() to execute the default strings. The values in instance_config and local_config_overrides, however, are used as is. As such, each option or constant specified in one of those files must be fully specified within that file - it can’t, for instance, use the INSTANCE_ROOT value to construct paths unless it defines it for itself.
  • Configuration constants will be set in the instance and local config modules. Configuration options will not.

Configuration Options

Option Default Description
Options to configure paths for various local resources
AUDIT_PATH os.path.join(INSTANCE_ROOT, ‘manual-audit’) Folder where files generated for manual audit should be stored
SVN_ROOT os.path.join(INSTANCE_ROOT, ‘projects’) Common ancestor for all VCS checkout folders. While tendril will try to descend into this folder indefinitely, avoid using overly generic paths (like ‘/’ or ‘~’) to avoid surprises and preserve performance.
PROJECTS_ROOT SVN_ROOT Common ancestor for all project folders. Use this if your projectsare in a single sub-tree of your VCS_ROOT, for example. While tendril will try to descend into this folder indefinitely, avoid using overly generic paths (like ‘/’ or ‘~’) to avoid surprises and preserve performance.
INSTANCE_CACHE os.path.join(INSTANCE_ROOT, ‘cache’) Folder within which the tendril instance should store it’s cache(s).Make sure the the users running tendril (as well as the webserver, if the web frontend is being used) have write access to this folder.
Options to configure the ‘filesystems’ containing instance resources
DOCUMENT_WALLET_ROOT os.path.join(INSTANCE_ROOT, ‘wallet’) Folder for the document wallet filesystem
DOCSTORE_ROOT os.path.join(INSTANCE_ROOT, ‘docstore’) Folder for the docstore filesystem
REFDOC_ROOT os.path.join(INSTANCE_ROOT, ‘refdocs’) Folder for the refdocs filesystem
MQ_SERVER None Message Queue Server URL
Options to configure details of various instance resources
DOCUMENT_WALLET {} Dictionary containing keys and filenames of the documents in the wallet
PRINTER_NAME {} Name of the printer to use for printing. Tendril will use ‘lp -d PRINTER_NAME to print.
Options to configure third-party infrastructure services integration
APPENLIGHT_PRIVATE_API_KEY {} Private API key to use with appenlight, if any.
APPENLIGHT_PUBLIC_API_KEY {} Public API key to use with appenlight, if any.
ENABLE_APPENLIGHT False Whether to use AppEnlight to monitor application.
PIWIK_SITE_ID {} Site ID to use with Piwik.
PIWIK_BASE_URL {} Base URL of the Piwik instance to use.
ENABLE_PIWIK False Whether to use Piwik for analytics.
Options to configure the gEDA installation and related resources
GEDA_SCHEME_DIR ‘/usr/share/gEDA/scheme’ The ‘scheme’ directory of the gEDA installation to use.
USE_SYSTEM_GAF_BIN True Whether to use the gEDA binary located in system PATH. This config option is present to allow you to switch the gEDA instance tendril uses from your system default to a manually installed later version.In order to generate schematic PDFs on a headless install, you need to have a version of gEDA that includes the `gaf` tool.
GAF_BIN_ROOT None If system gEDA binaries are not to be used, specify the path to the ‘bin’ folder where the correct ‘gEDA’ binaries go.
GAF_ROOT os.path.join(os.path.expanduser(‘~’), ‘gEDA2’) The path to your gEDA gaf folder (named per the gEDA quickstart tutorial), within which you have your symbols, footprints, etc.
GEDA_SYMLIB_ROOT os.path.join(GAF_ROOT, ‘symbols’) The folder containing your gEDA symbols.
GEDA_SUBCIRCUITS_ROOT os.path.join(GAF_ROOT, ‘pieces’) The folder containing schematics for your gEDA subcircuit symbols.
MAKE_GSYMLIB_IMG_CACHE True Whether or not to generate the gsymlib image cache.
Options to configure network caching behavior
ENABLE_REDIRECT_CACHING True Whether or not to cache 301 and 302 redirects.
MAX_AGE_DEFAULT 600000 Default max_age for data originating from www.
FIREFOX_PROFILE_PATH None Path to the firefox profile to use for splinter.
Options to configure a network proxy
NETWORK_PROXY_TYPE None The type of proxy to use. ‘http’ for squid/http, ‘None’ for none.No other proxy types presently supported.
NETWORK_PROXY_IP None The proxy server IP address.
NETWORK_PROXY_PORT 3128 The proxy server port.
NETWORK_PROXY_USER None The username to authenticate with the proxy server.
NETWORK_PROXY_PASS None The password to authenticate with the proxy server.
Options to configure the instance database
DATABASE_HOST None The database server host.
DATABASE_PORT 5432 The database server port.
DATABASE_USER None The username to login to the database server.
DATABASE_PASS None The password to login to the database server.
DATABASE_DB None The name of the database.
Options to configure the frontend
USE_X_SENDFILE True Whether to use X-SENDFILE to send files from the web frontend. Note that your web server must also support and be configured to do this.
Options to configure e-mail
MAIL_USERNAME None The username to authenticate with the SMTP server
MAIL_PASSWORD None The password to authenticate with the SMTP server
MAIL_DEFAULT_SENDER None The sender to use when sending emails
MAIL_SERVER None The host of the SMTP server to use
MAIL_PORT None The port of the SMTP server to use
MAIL_PORT 587 The port of the SMTP server to use
MAIL_USE_SSL True Whether to use SSL when sending emails
MAIL_USE_TLS False Whether to use TLS when sending emails
Options to configure security features
ADMIN_USERNAME None The username for the first Admin user
ADMIN_FULLNAME None The full name for the first Admin user
ADMIN_EMAIL None The e-mail for the first Admin user
ADMIN_PASSWORD None The password for the first Admin user
SECRET_KEY None The secret key for the frontend authentication system
Options to configure company details
COMPANY_NAME None The full name of the company
COMPANY_NAME_SHORT COMPANY_NAME A shortened name for the company
COMPANY_EMAIL MAIL_DEFAULT_SENDER The company email address
COMPANY_ADDRESS_LINE None The company address, in a single line
COMPANY_LOGO_PATH None The path to the company logo, relative to INSTANCE_ROOT
COMPANY_BLACK_LOGO_PATH None The path to the company logo for use on a black background, relative to INSTANCE_ROOT
COMPANY_PO_LCO_PATH None The path to the company lco file for use with latex scrlttr2, relative to INSTANCE_ROOT
COMPANY_GOVT_POINT None The name of the person who signs documents outbound to the government
COMPANY_PO_POINT None The name of the person who signs documents outbound to vendors
COMPANY_IEC None The company import-exchange code
INSTANCE_SOURCES “https://github.com/chintal/tendril” The location of the sources of the tendril code used by the instance
INSTANCE_FOLDER_SOURCES “https://github.com/chintal/tendril-instance-cookiecutter” The location of the sources of the tendril instance folder used by the instance
INSTANCE_DOCUMENTATION_PATH “http://tendril.chintal.in/doc” The location of the documentation related to the instance
Options to configure inventory details
INVENTORY_LOCATIONS [] A list of names of inventory locations
ELECTRONICS_INVENTORY_DATA [] A list of dictionaries specifying the locations and formats of inventory data.
Options to configure vendor details
VENDOR_MAP_FOLDER os.path.join(INSTANCE_ROOT, ‘sourcing’, ‘maps’) The folder in which vendor maps should be dumped
VENDOR_DEFAULT_MAXAGE -1 The maximum age in seconds after which sourcing information is considered stale. Set to -1 for no checks. The continuous background update is pretty unwieldy.
OCTOPART_API_KEY None The OctoPart API Key to use for vendors based on the OctoPart API.
VENDOR_MAP_AUDIT_FOLDER os.path.join(AUDIT_PATH, ‘vendor-maps’) The folder in which the vendor maps audits should be dumped
PRICELISTVENDORS_FOLDER os.path.join(INSTANCE_ROOT, ‘sourcing’, ‘pricelists’) The folder in which the price lists for pricelist vendors are located.
CUSTOMSDEFAULTS_FOLDER os.path.join(INSTANCE_ROOT, ‘sourcing’, ‘customs’) The folder in which customs defaults are located.
VENDORS_DATA [] A list of dictionaries containing vendor details, one for eachconfigured vendor.
Options to configure tendril execution behavior
SUPPORT_INTERPRETER_PERSISTENCE False Whether tendril should support interpreter persistence. This is generally in the form of maintaining in-memory caches, reloading sources from the filesystem, etc. This slows startup time, and therefore is only appropriate for server deployments.
WARM_UP_CACHES False Whether tendril caches should be warmed up on startup. This significantly slows startup time, and therefore is only appropriate for server deployments.

Configuration Constants

Option Default Description
Basic config constants
TENDRIL_ROOT os.path.normpath(os.path.join(CONFIG_PATH, os.pardir, os.pardir)) Path to the tendril package root.
INSTANCE_ROOT os.path.join(os.path.expanduser(‘~’), ‘.tendril’) Path to the tendril instance root. Can be redirected if necessarywith a file named ``redirect`` in this folder.
Configuration constants, following INSTANCE_ROOT redirection if needed
INSTANCE_CONFIG_FILE os.path.join(INSTANCE_ROOT, ‘instance_config.py’) Path to the tendril instance configuration.
LOCAL_CONFIG_FILE os.path.join(INSTANCE_ROOT, ‘local_config_overrides.py’) Path to local overrides to the instance configuration.
DOX_TEMPLATE_FOLDER os.path.join(TENDRIL_ROOT, ‘dox/templates’) Path to the template folder to use for tendril.dox
Filesystems related constants
DOCUMENT_WALLET_PREFIX ‘wallet’ Prefix for the Document Wallet in the expose hierarchy
DOCSTORE_PREFIX ‘docstore’ Prefix for the Docstore in the expose hierarchy
REFDOC_PREFIX ‘refdocs’ Prefix for refdocs in the expose hierarchy
class tendril.utils.config.ConfigConstant(name, default, doc)[source]

Bases: object

A configuration constant. This is fully specified in this file and cannot be changed by the user or the instance administrator without modifying the core code.

The value itself is constructed using eval().

value
tendril.utils.config.load_constants(constants)[source]

Loads the constants in the provided list into the module namespace.

Parameters:constants – list of ConfigConstant
Returns:None
tendril.utils.config.get_svn_path(fpath)[source]
class tendril.utils.config.ConfigOption(name, default, doc)[source]

Bases: object

A configuration option. These options can be overridden by specifying them in the instance_config and local_config_overrides files.

If specified in one of those files, the value should be the actual configuration value and not an expression. The default value specified here is used through eval().

value
tendril.utils.config.load_config(options)[source]

Loads the options in the provided list into the module namespace.

Parameters:options – list of ConfigOption
Returns:None
tendril.utils.config.build_db_uri(dbhost, dbport, dbuser, dbpass, dbname)[source]

Builds a postgresql DB URI from the parameters provided.

Parameters:
  • dbhost – Hostname / IP of the database server
  • dbport – Port of the database server
  • dbuser – Username of the database user
  • dbpass – Password of the database user
  • dbname – Name of the database
Returns:

The DB URI

tendril.utils.config.doc_render(group)[source]

Converts a list of ConfigOption or ConfigConstant into a list compatible with sphinxcontrib.documentedlist for generating the configuration parameter documentation.