[Zope-dev] Programmatic way to get the Zope Version

Steve Alexander steve@cat-box.net
Sun, 11 Feb 2001 17:42:55 +0000


Chris Withers wrote:

> Hi,
> 
> I was if do something like:
> 
> if zope_version >= 2.3:
>   # balh
> else:
>   # blah
> 
> Where do I get the zope_version bti and what format will it be in?

You can get it as version_txt from Control_Panel. For example, from DTML:

<dtml-with Control_Panel>
  <dtml-var version_txt>
</dtml-with>

However, this won't do you much good, as when you have a version
of Zope from CVS, it gets called "(unreleased version)".

The way some Products detect the version is to try to import a
module that only exists in one version of Zope, or try to look up
an attribute that is only in one version of Zope, and then catch
the Exception. Ideally, this will be the attribute or module that
has changed that made you want to detect the version in the first
place.

Make your choices based on whether there is an Exception or not.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net