Add convenience function for core_office_url() config

This commit is contained in:
Lance Edgar 2020-03-14 18:38:12 -05:00
parent af1e38aa18
commit ffd451a700

View file

@ -47,3 +47,18 @@ class RattailCOREPOSExtension(ConfigExtension):
config.coretrans_engines = engines config.coretrans_engines = engines
config.coretrans_engine = engines.get('default') config.coretrans_engine = engines.get('default')
CoreTransSession.configure(bind=config.coretrans_engine) CoreTransSession.configure(bind=config.coretrans_engine)
def core_office_url(config, require=False, **kwargs):
"""
Returns the base URL for the CORE Office web app. Note that this URL will
*not* have a trailing slash.
"""
args = ['corepos', 'office.url']
if require:
url = config.require(*args, **kwargs)
return url.rstrip('/')
else:
url = config.get(*args, **kwargs)
if url:
return url.rstrip('/')