How to check if my product is already installed when installing it?

I want to execute parts of my code at the import stage only if the product itself is not already installed.

I tried using the listInstalledProduct method for a quick installation tool.

However, this will return all installed prods, but not my own.

How can I check if my product is already installed on the site?

+4
source share
1 answer

With the right hint of Ann Walter (aka 'awello'), I could find a solution:

from Products.CMFCore.utils import getToolByName def myMethod(context): qi = getToolByName(context, 'portal_quickinstaller') prods = qi.listInstallableProducts(skipInstalled=False) for prod in prods: if (prod['id'] == 'your.productname') and (prod['status'] == 'new'): # further code... 

For some reason and, fortunately, the product status during reinstallation will be returned “uninstalled”, products not yet installed will be returned with the status “new” and, finally, already installed site runs shout loudly and proudly: 'installed'.

In this way, reinstallation can be distinguished from the initial installation.

+5
source

Source: https://habr.com/ru/post/1444301/


All Articles