diff --git a/rattail_corepos/config.py b/rattail_corepos/config.py index 69fe00f..8001866 100644 --- a/rattail_corepos/config.py +++ b/rattail_corepos/config.py @@ -47,3 +47,18 @@ class RattailCOREPOSExtension(ConfigExtension): config.coretrans_engines = engines config.coretrans_engine = engines.get('default') 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('/')