Skip to content

Commit

Permalink
Merge pull request #71 from plone/maurits/no-qi
Browse files Browse the repository at this point in the history
Removed backwards compatibility code for old quickinstaller.
  • Loading branch information
mauritsvanrees committed Oct 2, 2020
2 parents 631d7d8 + 37f5692 commit 5d36c61
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 58 deletions.
20 changes: 10 additions & 10 deletions docs/README.rst
Expand Up @@ -505,11 +505,11 @@ Product and profile installation
...

``quickInstallProduct(portal, productName, reinstall=False)``
Use this function to install a particular product into the given Plone
site, using the ``portal_quickinstaller`` tool. If ``reinstall`` is
``False`` and the product is already installed, nothing will happen; if
``reinstall`` is ``True``, the product will be reinstalled. The
``productName`` should be a full dotted name, e.g. ``Products.MyProduct``,
Use this function to install a particular product into the given Plone site,
using the add-ons control panel code (portal setup).
If ``reinstall`` is ``False`` and the product is already installed, nothing will happen.
If ``reinstall`` is true, perform an uninstall and install if the product is installed already.
The ``productName`` should be a full dotted name, e.g. ``Products.MyProduct``,
or ``my.product``.

For example::
Expand Down Expand Up @@ -1143,13 +1143,13 @@ To apply a particular extension profile::
This is the preferred method of installing a product's configuration.

To install an add-on product into the Plone site using the
``portal_quickinstaller`` tool::
add-ons control panel::

from plone.app.testing import quickInstallProduct

quickInstallProduct(portal, 'my.product')

To re-install a product using the quick-installer::
To uninstall and install a product using the add-ons control panel::

quickInstallProduct(portal, 'my.product', reinstall=True)

Expand All @@ -1164,10 +1164,10 @@ has been applied. Some of the more common such tests are shown below.
To verify that a product has been installed (e.g. as a dependency via
``metadata.xml``)::

from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import get_installer

quickinstaller = getToolByName(portal, 'portal_quickinstaller')
self.assertTrue(quickinstaller.isProductInstalled('my.product'))
qi = get_installer(portal)
self.assertTrue(qi.is_product_installed('my.product'))

To verify that a particular content type has been installed (e.g. via
``types.xml``)::
Expand Down
4 changes: 4 additions & 0 deletions news/1775.feature
@@ -0,0 +1,4 @@
Removed backwards compatibility code for old quickinstaller.
Current plone.app.testing is only for Plone 5.2+, so this code was no longer used.
See also `PLIP 1775 <https://github.com/plone/Products.CMFPlone/issues/1775>`_.
[maurits]
35 changes: 12 additions & 23 deletions src/plone/app/testing/helpers.py
Expand Up @@ -68,9 +68,10 @@ def tearDownMultiPluginRegistration(pluginName):


def quickInstallProduct(portal, productName, reinstall=False):
"""Install a product using the ``portal_quickinstaller`` tool. If
``reinstall`` is false and the product is already installed, do nothing.
If ``reinstall`` is true, perform an explicit reinstall if the product
"""Install a product using the add-ons control panel (portal setup).
If ``reinstall`` is false and the product is already installed, do nothing.
If ``reinstall`` is true, perform an uninstall and install if the product
is installed already.
"""

Expand All @@ -83,28 +84,16 @@ def quickInstallProduct(portal, productName, reinstall=False):

zope.login(app['acl_users'], SITE_OWNER_NAME)

try:
from Products.CMFPlone.utils import get_installer
except ImportError:
# BBB For Plone 5.0 and lower.
qi = portal['portal_quickinstaller']
old_qi = True
else:
qi = get_installer(portal)
old_qi = False
from Products.CMFPlone.utils import get_installer

qi = get_installer(portal)

try:
if old_qi:
if not qi.isProductInstalled(productName):
qi.installProduct(productName)
elif reinstall:
qi.reinstallProducts([productName])
else:
if not qi.is_product_installed(productName):
qi.install_product(productName, allow_hidden=True)
elif reinstall:
qi.uninstall_product(productName)
qi.install_product(productName, allow_hidden=True)
if not qi.is_product_installed(productName):
qi.install_product(productName, allow_hidden=True)
elif reinstall:
qi.uninstall_product(productName)
qi.install_product(productName, allow_hidden=True)

portal.clearCurrentSkin()
portal.setupCurrentSkin(portal.REQUEST)
Expand Down
18 changes: 6 additions & 12 deletions src/plone/app/testing/helpers.rst
Expand Up @@ -38,7 +38,7 @@ layer, we will perform the following setup:
4. Make some persistent changes, to illustrate how these are torn down when
we pop the ZODB ``DemoStorage``.

5. Install a product using the ``get_installer`` view (or the old ``portal_quickinstaller`` tool).
5. Install a product using the ``get_installer`` view.

6. Apply a named extension profile.

Expand All @@ -50,15 +50,9 @@ course, if our setup had changed any other global or external state, we would
need to tear that down as well.

>>> def is_installed(portal, product_name):
... try:
... from Products.CMFPlone.utils import get_installer
... except ImportError:
... # BBB For Plone 5.0 and lower.
... qi = portal['portal_quickinstaller']
... return qi.isProductInstalled(product_name)
... else:
... qi = get_installer(portal)
... return qi.is_product_installed(product_name)
... from Products.CMFPlone.utils import get_installer
... qi = get_installer(portal)
... return qi.is_product_installed(product_name)

>>> from plone.testing import Layer
>>> from plone.testing import zca, zope, zodb
Expand Down Expand Up @@ -106,7 +100,7 @@ need to tear that down as well.
... # Make some persistent changes
... portal.title = u"New title"
...
... # Install a product using portal_quickinstaller
... # Install a product using the addons control panel
... helpers.quickInstallProduct(portal, 'plone.app.testing')
... assert is_installed(portal, 'plone.app.testing')
...
Expand Down Expand Up @@ -155,7 +149,7 @@ having taken effect.
... print(portal.title)
New title

We should also see our product installation in the quickinstaller tool
We should also see our product installation in the add-ons control panel
and the results of the profile having been applied.

>>> from Products.GenericSetup.tool import UNKNOWN
Expand Down
13 changes: 0 additions & 13 deletions src/plone/app/testing/layers.py
Expand Up @@ -81,19 +81,6 @@ class PloneFixture(Layer):
except ImportError:
pass

# try:
# import Products.PasswordResetTool
# products = products + (
# ('Products.PasswordResetTool', {'loadZCML': True}, ),)
# except ImportError:
# pass
# try:
# import Products.CMFQuickInstallerTool
# products = products + (
# ('Products.CMFQuickInstallerTool', {'loadZCML': True}, ),)
# except ImportError:
# pass

# Extension profiles to be installed with site setup
extensionProfiles = (
'plonetheme.barceloneta:default',
Expand Down

0 comments on commit 5d36c61

Please sign in to comment.