Skip to content

Commit

Permalink
Add upgrade step for changes in 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
thet committed Mar 6, 2017
1 parent e77d983 commit 2880e48
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
7 changes: 4 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Changelog
=========

2.2 (unreleased)
----------------
2.1.1 (unreleased)
------------------

- Nothing changed yet.
- Add upgrade step for changes in 2.1 + register missing upgrade steps for Plone 5 migration.
[thet]


2.1 (2017-02-28)
Expand Down
10 changes: 9 additions & 1 deletion plone/formwidget/geolocation/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@
description="Migrate resources to new resource registry."
source="1"
destination="2"
handler="plone.formwidget.geolocation.upgrade_1_to_2"
handler="plone.formwidget.geolocation.upgrades.upgrade_1_to_2"
profile="plone.formwidget.geolocation:default"
/>
<genericsetup:upgradeStep
title="Remove unused resources"
description="Remove unused bundles and resources, which are now provided by plone.patternslib."
source="2"
destination="3"
handler="plone.formwidget.geolocation.upgrades.upgrade_2_to_3"
profile="plone.formwidget.geolocation:default"
/>

Expand Down
2 changes: 1 addition & 1 deletion plone/formwidget/geolocation/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>2</version>
<version>3</version>
<dependencies>
<dependency>profile-plone.patternslib:default</dependency>
</dependencies>
Expand Down
29 changes: 29 additions & 0 deletions plone/formwidget/geolocation/upgrades.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- coding: utf-8 -*-
from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import IResourceRegistry
from zope.component import getUtility

import logging


Expand Down Expand Up @@ -41,3 +45,28 @@ def upgrade_1_to_2(context):

setup = getToolByName(context, 'portal_setup')
setup.runImportStepFromProfile(PROFILE_ID, 'plone.app.registry')


def upgrade_2_to_3(context):
"""Remove unused bundles and resources.
"""

registry = getUtility(IRegistry)
records = registry.collectionOfInterface(
IResourceRegistry,
prefix='plone.resources',
check=False
)
if 'geolocation-bundle-resource' in records:
del records['geolocation-bundle-resource']

records = registry.collectionOfInterface(
IResourceRegistry,
prefix='plone.bundles',
check=False
)
if 'geolocation-bundle' in records:
del records['geolocation-bundle']

setup = getToolByName(context, 'portal_setup')
setup.runAllImportStepsFromProfile('profile-plone.patternslib:default')
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import find_packages
from setuptools import setup

version = '2.2.dev0'
version = '2.1.1'

setup(
name='plone.formwidget.geolocation',
Expand Down

0 comments on commit 2880e48

Please sign in to comment.