Dear all,

I noticed recently that Formulator does not work with CMF v2 because FSForm.py imports from CMFCore.CMFPermissions so I thought I'd fix this and thought it might be useful. Easier said than done as there does not seem to be a standard way to find out which version of CMF is installed which is presumably why the Plone installer devotes a few lines to it.

I've come up with the following:

# Use existing Zope tools to check for the CMFVersion
import App.Product
import OFS.Application
import os.path

CMFVERSION = None

for priority, product_name, index, product_dir in OFS.Application.get_products():
    if product_name == "CMFCore":
        class Dummy(object):
            """Dummy object for a dummy product install"""
            def _setObject(self, name, product):
                pass

        A = Dummy()
        A.Control_Panel = Dummy()
        A.Control_Panel.Products = Dummy()

        package_dir=os.path.join(product_dir, product_name)
        OFS.Application.import_product(product_dir, product_name)
        productObject = App.Product.initializeProduct(
                None, product_name, package_dir, A)
        version = productObject.version
        version = version.split("-")
        major = int(version[-1][0])
        if major >= 2:
            CMFVERSION = 2

I hope this isn't too weird! I think it is flexible enough to be used with other Zope Products if required but does beg the question: shouldn't there be an easier way to do this? Should there be a standard method of getting a Product's version in Zope.app? I assume there are other Products that have similar dependencies, although I am not sure if the problem is in FSForm itself which does some pretty thoughtless importing.

Charlie
--
Charlie Clark
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226



_______________________________________________
Zope-CMF maillist  -  Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to