feat: standardize how app, package versions are determined
This commit is contained in:
parent
b8ace1eb98
commit
2c2727bf66
|
@ -26,13 +26,12 @@ Tailbone Web API - "Common" Views
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import rattail
|
from rattail.util import get_pkg_version
|
||||||
|
|
||||||
from cornice import Service
|
from cornice import Service
|
||||||
from cornice.service import get_services
|
from cornice.service import get_services
|
||||||
from cornice_swagger import CorniceSwagger
|
from cornice_swagger import CorniceSwagger
|
||||||
|
|
||||||
import tailbone
|
|
||||||
from tailbone import forms
|
from tailbone import forms
|
||||||
from tailbone.forms.common import Feedback
|
from tailbone.forms.common import Feedback
|
||||||
from tailbone.api import APIView, api
|
from tailbone.api import APIView, api
|
||||||
|
@ -68,8 +67,8 @@ class CommonView(APIView):
|
||||||
return app.get_title()
|
return app.get_title()
|
||||||
|
|
||||||
def get_project_version(self):
|
def get_project_version(self):
|
||||||
import tailbone
|
app = self.get_rattail_app()
|
||||||
return tailbone.__version__
|
return app.get_version()
|
||||||
|
|
||||||
def get_packages(self):
|
def get_packages(self):
|
||||||
"""
|
"""
|
||||||
|
@ -77,8 +76,8 @@ class CommonView(APIView):
|
||||||
'about' page.
|
'about' page.
|
||||||
"""
|
"""
|
||||||
return OrderedDict([
|
return OrderedDict([
|
||||||
('rattail', rattail.__version__),
|
('rattail', get_pkg_version('rattail')),
|
||||||
('Tailbone', tailbone.__version__),
|
('Tailbone', get_pkg_version('Tailbone')),
|
||||||
])
|
])
|
||||||
|
|
||||||
@api
|
@api
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2022 Lance Edgar
|
# Copyright © 2010-2024 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -27,11 +27,11 @@ Note that most of the code for this module was copied from the beaker and
|
||||||
pyramid_beaker projects.
|
pyramid_beaker projects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from pkg_resources import parse_version
|
from pkg_resources import parse_version
|
||||||
|
|
||||||
|
from rattail.util import get_pkg_version
|
||||||
|
|
||||||
import beaker
|
import beaker
|
||||||
from beaker.session import Session
|
from beaker.session import Session
|
||||||
from beaker.util import coerce_session_params
|
from beaker.util import coerce_session_params
|
||||||
|
@ -49,7 +49,7 @@ class TailboneSession(Session):
|
||||||
"Loads the data from this session from persistent storage"
|
"Loads the data from this session from persistent storage"
|
||||||
|
|
||||||
# are we using older version of beaker?
|
# are we using older version of beaker?
|
||||||
old_beaker = parse_version(beaker.__version__) < parse_version('1.12')
|
old_beaker = parse_version(get_pkg_version('beaker')) < parse_version('1.12')
|
||||||
|
|
||||||
self.namespace = self.namespace_class(self.id,
|
self.namespace = self.namespace_class(self.id,
|
||||||
data_dir=self.data_dir,
|
data_dir=self.data_dir,
|
||||||
|
|
|
@ -170,6 +170,7 @@ def before_render(event):
|
||||||
renderer_globals = event
|
renderer_globals = event
|
||||||
renderer_globals['rattail_app'] = app
|
renderer_globals['rattail_app'] = app
|
||||||
renderer_globals['app_title'] = app.get_title()
|
renderer_globals['app_title'] = app.get_title()
|
||||||
|
renderer_globals['app_version'] = app.get_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,12 +24,11 @@
|
||||||
Various common views
|
Various common views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import importlib
|
|
||||||
import os
|
import os
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from rattail.batch import consume_batch_id
|
from rattail.batch import consume_batch_id
|
||||||
from rattail.util import simple_error
|
from rattail.util import get_pkg_version, simple_error
|
||||||
from rattail.files import resource_path
|
from rattail.files import resource_path
|
||||||
|
|
||||||
from tailbone import forms
|
from tailbone import forms
|
||||||
|
@ -109,9 +108,8 @@ class CommonView(View):
|
||||||
if hasattr(self, 'project_version'):
|
if hasattr(self, 'project_version'):
|
||||||
return self.project_version
|
return self.project_version
|
||||||
|
|
||||||
pkg = self.rattail_config.app_package()
|
app = self.get_rattail_app()
|
||||||
mod = importlib.import_module(pkg)
|
return app.get_version()
|
||||||
return mod.__version__
|
|
||||||
|
|
||||||
def exception(self):
|
def exception(self):
|
||||||
"""
|
"""
|
||||||
|
@ -136,10 +134,9 @@ class CommonView(View):
|
||||||
Should return the full set of packages which should be displayed on the
|
Should return the full set of packages which should be displayed on the
|
||||||
'about' page.
|
'about' page.
|
||||||
"""
|
"""
|
||||||
import rattail, tailbone
|
|
||||||
return OrderedDict([
|
return OrderedDict([
|
||||||
('rattail', rattail.__version__),
|
('rattail', get_pkg_version('rattail')),
|
||||||
('Tailbone', tailbone.__version__),
|
('Tailbone', get_pkg_version('Tailbone')),
|
||||||
])
|
])
|
||||||
|
|
||||||
def change_theme(self):
|
def change_theme(self):
|
||||||
|
|
Loading…
Reference in a new issue