Detect ZOPE version inside a product
Hi How could I detect the running Zope version inside a product? I need to do that at the module level, in the initialization stage. Gabriel Genellina Softlab SRL
Hi Gabriel, --On Freitag, 6. Dezember 2002 04:07 -0300 Gabriel Genellina <gagenellina@softlab.com.ar> wrote:
Hi
How could I detect the running Zope version inside a product? I need to do that at the module level, in the initialization stage.
I'm not sure if its wise to make decicions based on version numbers. You cant know if the user of your product has a highly patched version of zope which whould in fact allow her to run your product. I'd suggest to check for existence of methods and objects and wether they work as expected which are essential for your product. Provide the user with appropriate error messages if not. Regards Tino
At 10:05 6/12/2002 +0100, you wrote:
How could I detect the running Zope version inside a product? I need to do that at the module level, in the initialization stage.
I'm not sure if its wise to make decicions based on version numbers. You cant know if the user of your product has a highly patched version of zope which whould in fact allow her to run your product.
I'd suggest to check for existence of methods and objects and wether they work as expected which are essential for your product. Provide the user with appropriate error messages if not.
Since version 2.6 Zope changes its working directory to /var, earlier versions didn't, and I had to know that path. As you noted, relying in the version information is not very safe. I'm using now sys.modules['__builtin__'].CLIENT_HOME, that's fine, I presume. Gabriel Genellina Softlab SRL
Tino may be right, but I do this:: try: v = open(os.path.join(SOFTWARE_HOME,'version.txt')).read() m = re.match(r'(?i)zope\s*([0-9]+)\.([0-9]+)\.([0-9]+)',v) ZOPEVERSION = (int(m.group(1)),int(m.group(2)),int(m.group(3))) except: # if we can't read version.txt, assume we're dealing with a # highly advanced specimen.. (cvs) ZOPEVERSION = (9,9,9)
Tino is right, you have a mis-match between the ZODB objects and the file system. The version information of the Product from the file system can be found through Zope: ## Script (Python) "version" ##parameters=productName p = getattr(context.Control_Panel.Products, productName, None) if p: return p.version return "No product of that name found" -- Andy McKay ----- Original Message ----- From: "Simon Michael" <simon@joyful.com> To: <zope@zope.org> Sent: Friday, December 06, 2002 9:22 AM Subject: [Zope] Re: Detect ZOPE version inside a product
Tino may be right, but I do this::
try: v = open(os.path.join(SOFTWARE_HOME,'version.txt')).read() m = re.match(r'(?i)zope\s*([0-9]+)\.([0-9]+)\.([0-9]+)',v) ZOPEVERSION = (int(m.group(1)),int(m.group(2)),int(m.group(3))) except: # if we can't read version.txt, assume we're dealing with a # highly advanced specimen.. (cvs) ZOPEVERSION = (9,9,9)
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Gabriel Genellina writes:
How could I detect the running Zope version inside a product? I need to do that at the module level, in the initialization stage. See, whether you find something appropriate in "App/version_txt.py".
Dieter
participants (5)
-
Andy McKay -
Dieter Maurer -
Gabriel Genellina -
Simon Michael -
Tino Wildenhain