Updated configuration interface to display inner package name and version
authorThierry Florac <thierry.florac@onf.fr>
Tue, 18 Apr 2017 11:59:50 +0200
changeset 181 2a582df9842b
parent 180 4ab1f514b9f0
child 182 25fc888b0b7e
Updated configuration interface to display inner package name and version
src/pyams_skin/configuration.py
src/pyams_skin/interfaces/configuration.py
--- a/src/pyams_skin/configuration.py	Tue Apr 18 11:40:10 2017 +0200
+++ b/src/pyams_skin/configuration.py	Tue Apr 18 11:59:50 2017 +0200
@@ -54,6 +54,8 @@
 
     application_package = 'pyams_skin'
     application_name = 'PyAMS'
+    inner_package = None
+    inner_package_name = None
 
     version_location = 'menus'
 
@@ -77,7 +79,11 @@
 
     @property
     def version(self):
-        return pkg_resources.get_distribution(self.application_package).version
+        result = pkg_resources.get_distribution(self.application_package).version
+        if self.inner_package:
+            result += ' (%s v%s)' % (self.inner_package_name,
+                                     pkg_resources.get_distribution(self.inner_package).version)
+        return result
 
 
 @adapter_config(name='static_configuration', context=(Interface, Interface, Interface), provides=ITALESExtension)
--- a/src/pyams_skin/interfaces/configuration.py	Tue Apr 18 11:40:10 2017 +0200
+++ b/src/pyams_skin/interfaces/configuration.py	Tue Apr 18 11:59:50 2017 +0200
@@ -40,6 +40,14 @@
                                 description="This name is used to display application version",
                                 required=False)
 
+    inner_package = TextLine(title=_("Inner package"),
+                             description=_("This is another important package displayed in application version"),
+                             required=False)
+
+    inner_package_name = TextLine(title=_("Inner package name"),
+                                  description=_("Package name used to display application version"),
+                                  required=False)
+
     version = Attribute("Application version")
 
     version_location = Choice(title="Version label location",