Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package does not uninstall cleanly #24

Open
frisi opened this issue Nov 21, 2016 · 2 comments

Comments

@frisi
Copy link
Member

commented Nov 21, 2016

a former colleague installed collective.geo.bundle on a plonesite and we removed it later in the project.
after that i got errors when running installers of other packages

  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 451, in snapshotPortal
  Module five.localsitemanager.registry, line 234, in registeredUtilities
  Module zope.component.registry, line 159, in registeredUtilities
  Module ZODB.Connection, line 860, in setstate
  Module ZODB.Connection, line 914, in _setstate
  Module ZODB.serialize, line 612, in setGhostState
  Module ZODB.serialize, line 605, in getState
  Module copy_reg, line 48, in _reconstructor
TypeError: ('object.__new__(DefaultMapLayers) is not safe, use persistent.Persistent.__new__()', <function _reconstructor at 0x7f212ed73aa0>, (<class 'collective.geo.mapwidget.maplayers.DefaultMapLayers'>, <type 'object'>, None))

it took me a few hours to fix the portal with the following upgrade steps.
as a reference for other people that might experience the same issue and/or as a basis for the uninstall profile:

persistent utility

Plone/manage_components
listed the utility and removing it with GS was not enough

    <componentregistry>
    <utilities>
    <utility
        interface="collective.geo.mapwidget.interfaces.IDefaultMapLayers"
        factory="collective.geo.mapwidget.maplayers.DefaultMapLayers" 
         remove="True"/>
    </utilities>
    </componentregistry>

i needed an upgrade step::

def remove_components(context):
    # http://blog.keul.it/2013/05/how-to-make-your-plone-add-on-products.html
    # http://docs.plone.org/4/en/manage/troubleshooting/manual-remove-utility.html

    # make sure to import colletive.geo.mapwidget:default profile before so the
    # utility is properly registered
    portal = api.portal.get()
    sm = portal.getSiteManager()

    from collective.geo.mapwidget.interfaces import IDefaultMapLayers
    # util = sm.getUtility(IDefaultMapLayers)
    # getUtility did not work on my portal - problem could be fixed w/o del in my case
    sm.unregisterUtility(provided=IDefaultMapLayers)
    # del util
    # del sm.utilities.__dict__['_provided'][IDefaultMapLayers]
    # del sm.utilities._subscribers[0][IDefaultMapLayers]

registry

i could not remove all registry settings via GenericSetup:

<registry>
    <records interface="collective.geo.settings.interfaces.IGeoSettings" remove="True" />
    <records interface="collective.geo.settings.interfaces.IGeoFeatureStyle" remove="True" />
</registry>

i got the following error when running the profile::

    Module plone.registry.registry, line 78, in forInterface
    KeyError: 'Interface `collective.geo.settings.interfaces.IGeoSettings` defines a field `geo_content_types`, for which there is no record.'

so i wrote an upgrade step that iterates over all fields of an interface and tries to delete the records for these files (if they exist)

def remove_registryrecords(context):

    # can't use registry.xml purge="True" because interface contains fields
    # that are not present in the registry

    registry = getUtility(IRegistry)
    interfaces = [
        'collective.geo.settings.interfaces.IGeoSettings',
        'collective.geo.settings.interfaces.IGeoFeatureStyle']

    for iface_name in interfaces:
        iface = resolve(iface_name)
        for field_name in getFieldNames(iface):
            name = "%s.%s" % (iface_name, field_name)
            if name in registry.records:
                del registry.records[name]
            else:
                logger.warn("skipping non existent record:" + name)

browserlayers

Plone/manage_components listed some local browserlayers that i removed like so:

def remove_localbrowserlayers(context):
    # removing these in componentregistry.xml does not work and
    # seems not to be needed (in contrary to the IDefaultMapLayers utlity)
    portal = api.portal.get()
    sm = portal.getSiteManager()
    from plone.browserlayer.utils import unregister_layer
    from plone.browserlayer.interfaces import ILocalBrowserLayerType

    names = [
        u'collective.geo.mapwidget',
        u'collective.geo.contentlocations',
        u'collective.geo.kml',
        u'collective.geo.openlayers',
        ]
    logger.info('removing local browser layers')
    for name in names:
        # does not work because utilities can't be looked up anymore
        # would need to reinsall the packages to make this work
        # unregister_layer(name)

        # alternative that seems to work: delete manually:
        try:
            sm.unregisterUtility(
                provided=ILocalBrowserLayerType,
                name=name)
        except KeyError, e:
            logger.warn(str(e))
@NikDuk

This comment has been minimized.

Copy link

commented Nov 26, 2017

Since days we try to migrate an instance from Plone 4 to Plone 5 on which the collective.geo.bundle was installed. Collective.geo.bundle is unable to uninstall. Now I have found your issue and hope this will fix the "problem".
What do we have to do? Where do we have to place and execute the code. Please could you explain it also for non plone extension programmers? Maybe we can post the steps to the documentation of the collective.geo.bundle (How can you remove collective.geo.bundle), because I think there are a lot of frustrated Plone users out there. Thank for help!

@frisi

This comment has been minimized.

Copy link
Member Author

commented Nov 28, 2017

Hi @NikDuk

The steps outlined above require a plone addon to run the generic setup steps (componentregistry.xml and registry.xml). so if you do not know how to create an addon you'll have to hire a developer.

I'd say it takes about 4 to 6 hours to add a uninstall profile to collective geo.mapwidget. this would solve your problems and also nerves of other users running into the same troubles.
we're very busy currently. you might ask for help in https://community.plone.org/ and ping me here if you can't find anybody to help you in the forum.

hope that helps ;-)
have a nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.