Use pkg_resources
to determine package versions
and always add `app_version` to global template context. this was for sake of "About This App v1.0.0" style links in custom page footers
This commit is contained in:
parent
ce290f5f8b
commit
f6f2a53a0c
|
@ -28,6 +28,7 @@ import six
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
import pkg_resources
|
||||||
import warnings
|
import warnings
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
@ -168,7 +169,11 @@ def before_render(event):
|
||||||
|
|
||||||
renderer_globals = event
|
renderer_globals = event
|
||||||
renderer_globals['rattail_app'] = request.rattail_config.get_app()
|
renderer_globals['rattail_app'] = request.rattail_config.get_app()
|
||||||
|
|
||||||
renderer_globals['app_title'] = request.rattail_config.app_title()
|
renderer_globals['app_title'] = request.rattail_config.app_title()
|
||||||
|
pkg = rattail_config.app_package()
|
||||||
|
renderer_globals['app_version'] = pkg_resources.get_distribution(pkg).version
|
||||||
|
|
||||||
renderer_globals['h'] = helpers
|
renderer_globals['h'] = helpers
|
||||||
renderer_globals['url'] = request.route_url
|
renderer_globals['url'] = request.route_url
|
||||||
renderer_globals['rattail'] = rattail
|
renderer_globals['rattail'] = rattail
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
Various common views
|
Various common views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import importlib
|
|
||||||
import os
|
import os
|
||||||
|
import pkg_resources
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from rattail.batch import consume_batch_id
|
from rattail.batch import consume_batch_id
|
||||||
|
@ -108,8 +108,7 @@ class CommonView(View):
|
||||||
return self.project_version
|
return self.project_version
|
||||||
|
|
||||||
pkg = self.rattail_config.app_package()
|
pkg = self.rattail_config.app_package()
|
||||||
mod = importlib.import_module(pkg)
|
return pkg_resources.get_distribution(pkg).version
|
||||||
return mod.__version__
|
|
||||||
|
|
||||||
def exception(self):
|
def exception(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue