Skip to content

Commit

Permalink
fixed #1 and other minor undocumented issue with messages
Browse files Browse the repository at this point in the history
  • Loading branch information
keul committed Sep 13, 2012
1 parent 3d3965e commit 83a73a7
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 61 deletions.
10 changes: 5 additions & 5 deletions README.rst
Expand Up @@ -67,8 +67,8 @@ Migrate ATLink to Smart Link (and back)
---------------------------------------

Smart Link contains two Generic Setup import steps that can help you to transform all you ATLink
to Smart Link, or to go back to ATLink if you don't like Smart Link anymore (in that case: first
uninstall Smart Link, the run the import step).
to Smart Link, or to go back to ATLink if you don't like Smart Link anymore (automatically done
when you uninstall the product).

Warning 1
---------
Expand All @@ -92,13 +92,13 @@ Safe re-install, clean uninstall

You can *re-install* Smart Link safely for upgrade task or for restore changes, without any problem.

If you *uninstall* it, all data from Smart Link will be removed. This means that if you re-install it after
all your internal links will not be linked to target contents.
If you *uninstall* it, all data from Smart Link will be removed. This means that if you re-install
it after all your internal links will not be linked to target contents.

Requirements
============

Smart Link has been tested on Plone 3.3, 4.0, 4.1 and 4.2 (rc1).
Smart Link has been tested on Plone 3.3, 4.0, 4.1 and 4.2.
It's possible that also older Plone 3.x version can be used safely.

TODO and know issue
Expand Down
18 changes: 18 additions & 0 deletions docs/HISTORY.txt
@@ -1,6 +1,24 @@
Changelog
=========

1.1.3 (unreleased)
------------------

* Smart Link uninstall was changing the Generic Setup baseline context.
When we found it, we restore the "``profile-Products.CMFPlone:plone``"
(part of issue `#1`__)
[keul]
* when uninstalling, restore old ATLink automatically
[keul]
* fixed many bad formatted portal messages visualization
[keul]
* uninstall now remove the persisten utility (fix the other
part of issue `#1`__)
[keul]

__ https://github.com/RedTurtle/redturtle.smartlink/issues/1
__ https://github.com/RedTurtle/redturtle.smartlink/issues/1

1.1.2 (2012-05-23)
------------------

Expand Down
27 changes: 13 additions & 14 deletions redturtle/smartlink/Extensions/install.py
@@ -1,39 +1,41 @@
# -*- coding: utf-8 -*-

from redturtle.smartlink import logger
import transaction

from zope import interface
from zope.component import getUtility

from Products.CMFPlone.utils import getFSVersionTuple

from redturtle.smartlink import logger
from redturtle.smartlink.interfaces import ILinkNormalizerUtility
from redturtle.smartlink.interfaces import ISmartLinked
from redturtle.smartlink.interfaces.utility import ISmartlinkConfig
from redturtle.smartlink import smartlinkMessageFactory as _

def install(portal, reinstall=False):
setup_tool = portal.portal_setup
setup_tool.setBaselineContext('profile-redturtle.smartlink:default')
setup_tool.runAllImportStepsFromProfile('profile-redturtle.smartlink:default')
if not reinstall:
portal.plone_utils.addPortalMessage(_('install_info',
default=u'Starting from now, all Links created in this site will be Smart Link.\n'
u'If you have already created Link types in this site, you can migrate '
u'them to Smart Link using the "Smart Link: migrate ATLink to Smart Link" '
u'import step.'),
u'them to Smart Link from the site control panel (Configure Smart Link).'),
type='info')


def uninstall(portal, reinstall=False):
setup_tool = portal.portal_setup
setup_tool.setBaselineContext('profile-redturtle.smartlink:uninstall')
setup_tool.runAllImportStepsFromProfile('profile-redturtle.smartlink:uninstall')
if getFSVersionTuple()[0]>=4:
unregisterIcon(portal)
if not reinstall:
removeSmartLinkMarks(portal)
portal.plone_utils.addPortalMessage(_('uninstall_warning',
default=u'Keep in mind that contents created with Smart Link are still using Smart Link code '
u'and they will be broken if you remove the product from your Plone installation.\n'
u'You can convert them back to basic ATLink using the "Smart Link: migrate from Smart Link to ATLink" '
u'import step.'),
type='warning')
setup_tool.runAllImportStepsFromProfile('profile-redturtle.smartlink:smartLinkToATLink')
logger.info("...done. Thanks you for using me!")
portal.plone_utils.addPortalMessage(_('uninstall_info',
default=u'All of yours Smart Link contents has been transformed back to Plone ATLink'),
type='info')


def removeSmartLinkMarks(portal):
Expand All @@ -49,9 +51,6 @@ def removeSmartLinkMarks(portal):
interface.noLongerProvides(content, ISmartLinked)
content.reindexObject(['object_provides'])
logger.info(" unmarked %s" % '/'.join(content.getPhysicalPath()))
logger.info("...done. Thanks you for using me!")

# TODO: the perfect world is the one where SmartLink(s) are converted back to ATLink(s)


def unLink(portal, object):
Expand Down
16 changes: 13 additions & 3 deletions redturtle/smartlink/browser/migrate.py
Expand Up @@ -6,9 +6,11 @@
from five.formlib import formbase
except ImportError: # < 4.1
from Products.Five.formlib import formbase
from redturtle.smartlink.migrator import migrateSmartLink, migrateLinkToSmartLink

from Products.CMFCore.utils import getToolByName
from Products.statusmessages.interfaces import IStatusMessage

from redturtle.smartlink.migrator import migrateSmartLink, migrateLinkToSmartLink
from redturtle.smartlink import smartlinkMessageFactory as _

try:
Expand All @@ -29,8 +31,16 @@ class MigrateBlobs(formbase.PageForm):
@form.action(_(u'Migrate'))
def actionMigrate(self, action, data):
if MIGRATION_MODULE:
output = migrateSmartLink(self.context)
IStatusMessage(self.request).addStatusMessage(output, type='info')
messages = migrateSmartLink(self.context)
i = 0
for m in messages:
i+=1
IStatusMessage(self.request).addStatusMessage(m, type='info')
portal = getToolByName(self.context, 'portal_url').getPortalObject()
portal.plone_utils.addPortalMessage(_('sequence_help_message',
default=u"$num element(s) migrated",
mapping={'num': i}))

return self.request.response.redirect(self.context.absolute_url())
else:
output = _(u'migration_error_msg',
Expand Down
2 changes: 1 addition & 1 deletion redturtle/smartlink/configure.zcml
Expand Up @@ -53,7 +53,7 @@
<!-- Register the uninstallation GenericSetup extension profile -->
<genericsetup:registerProfile
name="uninstall"
title="Uninstall Smart Link"
title="Smart Link: uninstall"
directory="profiles/uninstall"
description="Remove Smart Link component"
provides="Products.GenericSetup.interfaces.EXTENSION"
Expand Down
1 change: 1 addition & 0 deletions redturtle/smartlink/interfaces/__init__.py
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from link import ISmartLink, ISmartLinked
from utility import ILinkNormalizerUtility
40 changes: 22 additions & 18 deletions redturtle/smartlink/locales/it/LC_MESSAGES/redturtle.smartlink.po
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: redturtle.smartlink\n"
"POT-Creation-Date: 2012-02-20 13:47+0000\n"
"POT-Creation-Date: 2012-09-13 13:55+0000\n"
"PO-Revision-Date: 2010-08-27 12:31+0200\n"
"Last-Translator: Federica D'Elia <federica.delia@redturtle.net>\n"
"Language-Team: it\n"
Expand All @@ -14,15 +14,15 @@ msgstr ""
"Preferred-Encodings: utf-8 latin1\n"
"Domain: redturtle.smartlink\n"

#: ../browser/migrate.py:26
#: ../browser/migrate.py:28
msgid "BLOBs Migration"
msgstr "Migrazione ai BLOB"

#: ../interfaces/utility.py:43
msgid "Back-end URLs"
msgstr "URL di back-end"

#: ../browser/migrate.py:42
#: ../browser/migrate.py:52
msgid "Cancel"
msgstr "Annulla"

Expand Down Expand Up @@ -59,19 +59,19 @@ msgstr "Ad un link di front end deve corrispondere un solo link di backend"
msgid "Front-end main URL"
msgstr "URL di front-end primario"

#: ../browser/migrate.py:29
#: ../browser/migrate.py:31
msgid "Migrate"
msgstr "Migrazione"

#: ../browser/migrate.py:49
#: ../browser/migrate.py:59
msgid "Migrate ATLink to Smart Link"
msgstr "Migrazione di ATLink a Smart Link"

#: ../browser/migrate.py:27
#: ../browser/migrate.py:29
msgid "Migrate Smart Link, making it use plone.app.blob"
msgstr "Migra Smart Link, facendogli usare plone.app.blob"

#: ../browser/migrate.py:50
#: ../browser/migrate.py:60
msgid "Migrate basic Plone ATLink to Smart Link"
msgstr "Migra gli ATLink base di Plone a Smart Link"

Expand Down Expand Up @@ -198,12 +198,12 @@ msgstr "Sarà visualizzata nelle viste che permettono di mostrare le immagini co
msgid "help_smartlink_internallink"
msgstr "Sfoglia per trovare la pagina interna che si desidera linkare. Se questo campo e' usato, il campo del link esterno verra' ignorato. Non e' possibile avere sia un collegamento interno che uno esterno"

#. Default: "Starting from now, all Links created in this site will be Smart Link.\nIf you have already created Link types in this site, you can migrate them to Smart Link using the \"Smart Link: migrate ATLink to Smart Link\" import step."
#: ../Extensions/install.py:15
#. Default: "Starting from now, all Links created in this site will be Smart Link.\nIf you have already created Link types in this site, you can migrate them to Smart Link from the site control panel (Configure Smart Link)."
#: ../Extensions/install.py:19
msgid "install_info"
msgstr ""
"Partendo da ora, tutti i Collegamenti creati in questo sito saranno Smart Link.\n"
"Se avevi già creato contenuto di tipo Collegamento, puoi migrarli al tipo Smart Link usando il profilo \"Smart Link: migrate ATLink to Smart Link\"."
"Se avevi già creato contenuto di tipo Collegamento, puoi migrarli al tipo Smart Link dal pannello di controllo (Configura Smart Link)."

#. Default: "This is an internal link to \"${internal_link_target}\""
#: ../browser/smartlink_view.pt:69
Expand Down Expand Up @@ -293,10 +293,16 @@ msgid "migrate your image fields to Plone blobs"
msgstr "migrare le tue immagini ai blob di Plone"

#. Default: "You need to install \"Products.contentmigration\" product for perform the task"
#: ../browser/migrate.py:36
#: ../browser/migrate.py:46
msgid "migration_error_msg"
msgstr "Devi installare \"Products.contentmigration\" per eseguire l'operazione"

#. Default: "$num element(s) migrated"
#: ../browser/migrate.py:40
#: ../setuphandlers.py:32
msgid "sequence_help_message"
msgstr "$num elemento(i) migrati"

#. Default: "Fill this configuration panel for production settings; choose if use relative paths, an unified front-end URL, or manually enter many back-end/front-end URL (for advanced installation).\nEvery configuration option take precedence on the one that follows.\nAfter changes you (probably) want to run the \"Update existing links\" task."
#: ../browser/configlet.py:41
msgid "setting_description"
Expand All @@ -305,16 +311,14 @@ msgstr ""
"Ogni opzione di configurazione ha la precedenza su quella che la segue.\n"
"Dopo le modifiche è probabile voler lanciare il processo \"Aggiorna i link esistenti\"."

#. Default: "Keep in mind that contents created with Smart Link are still using Smart Link code and they will be broken if you remove the product from your Plone installation.\nYou can convert them back to basic ATLink using the \"Smart Link: migrate from Smart Link to ATLink\" import step."
#: ../Extensions/install.py:31
msgid "uninstall_warning"
msgstr ""
"Tieni presente che i contenuti creati con Smart Link stanno ancora usando il codice di Smart Link e non saranno più funzionanti se rimuoverai il prodotto dalla tua installazione Plone.\n"
"Puoi ripristinarli ad essere normali ATLink usando il profilo \"Smart Link: migrate from Smart Link back to ATLink\"."
#. Default: "All of yours Smart Link contents has been transformed back to Plone ATLink"
#: ../Extensions/install.py:36
msgid "uninstall_info"
msgstr "Tutti i tuoi contenuti Smart Link sono stati ri-trasformati in ATLink Plone"

#. Default: "${count} elements updated"
#: ../browser/configlet.py:92
#: ../browser/migrate.py:59
#: ../browser/migrate.py:69
msgid "update_count_message"
msgstr "${count} elementi aggiornati"

34 changes: 20 additions & 14 deletions redturtle/smartlink/locales/redturtle.smartlink.pot
Expand Up @@ -4,7 +4,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2012-02-20 13:47+0000\n"
"POT-Creation-Date: 2012-09-13 13:55+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -17,15 +17,15 @@ msgstr ""
"Preferred-Encodings: utf-8 latin1\n"
"Domain: redturtle.smartlink\n"

#: ../browser/migrate.py:26
#: ../browser/migrate.py:28
msgid "BLOBs Migration"
msgstr ""

#: ../interfaces/utility.py:43
msgid "Back-end URLs"
msgstr ""

#: ../browser/migrate.py:42
#: ../browser/migrate.py:52
msgid "Cancel"
msgstr ""

Expand Down Expand Up @@ -61,19 +61,19 @@ msgstr ""
msgid "Front-end main URL"
msgstr ""

#: ../browser/migrate.py:29
#: ../browser/migrate.py:31
msgid "Migrate"
msgstr ""

#: ../browser/migrate.py:49
#: ../browser/migrate.py:59
msgid "Migrate ATLink to Smart Link"
msgstr ""

#: ../browser/migrate.py:27
#: ../browser/migrate.py:29
msgid "Migrate Smart Link, making it use plone.app.blob"
msgstr ""

#: ../browser/migrate.py:50
#: ../browser/migrate.py:60
msgid "Migrate basic Plone ATLink to Smart Link"
msgstr ""

Expand Down Expand Up @@ -198,8 +198,8 @@ msgstr ""
msgid "help_smartlink_internallink"
msgstr ""

#. Default: "Starting from now, all Links created in this site will be Smart Link.\nIf you have already created Link types in this site, you can migrate them to Smart Link using the \"Smart Link: migrate ATLink to Smart Link\" import step."
#: ../Extensions/install.py:15
#. Default: "Starting from now, all Links created in this site will be Smart Link.\nIf you have already created Link types in this site, you can migrate them to Smart Link from the site control panel (Configure Smart Link)."
#: ../Extensions/install.py:19
msgid "install_info"
msgstr ""

Expand Down Expand Up @@ -291,23 +291,29 @@ msgid "migrate your image fields to Plone blobs"
msgstr ""

#. Default: "You need to install \"Products.contentmigration\" product for perform the task"
#: ../browser/migrate.py:36
#: ../browser/migrate.py:46
msgid "migration_error_msg"
msgstr ""

#. Default: "$num element(s) migrated"
#: ../browser/migrate.py:40
#: ../setuphandlers.py:32
msgid "sequence_help_message"
msgstr ""

#. Default: "Fill this configuration panel for production settings; choose if use relative paths, an unified front-end URL, or manually enter many back-end/front-end URL (for advanced installation).\nEvery configuration option take precedence on the one that follows.\nAfter changes you (probably) want to run the \"Update existing links\" task."
#: ../browser/configlet.py:41
msgid "setting_description"
msgstr ""

#. Default: "Keep in mind that contents created with Smart Link are still using Smart Link code and they will be broken if you remove the product from your Plone installation.\nYou can convert them back to basic ATLink using the \"Smart Link: migrate from Smart Link to ATLink\" import step."
#: ../Extensions/install.py:31
msgid "uninstall_warning"
#. Default: "All of yours Smart Link contents has been transformed back to Plone ATLink"
#: ../Extensions/install.py:36
msgid "uninstall_info"
msgstr ""

#. Default: "${count} elements updated"
#: ../browser/configlet.py:92
#: ../browser/migrate.py:59
#: ../browser/migrate.py:69
msgid "update_count_message"
msgstr ""

3 changes: 1 addition & 2 deletions redturtle/smartlink/migrator.py
Expand Up @@ -8,8 +8,7 @@
from redturtle.smartlink.interfaces import ISmartLink

def migrateSmartLink(context):
return migrateBlob(context, 'Link', 'ATLink')

return migrateBlob(context, 'Link', 'ATLink').splitlines()

def isATLink(oldObject, **kwargs):
"""Test if the object is a simple ATLink (i.e: is not a Smart Link)"""
Expand Down
2 changes: 1 addition & 1 deletion redturtle/smartlink/profiles/default/metadata.xml
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<metadata>
<version>1002</version>
<version>1003</version>
</metadata>
8 changes: 8 additions & 0 deletions redturtle/smartlink/profiles/uninstall/componentregistry.xml
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<componentregistry>
<utilities>
<utility name="smartlink_config"
interface="redturtle.smartlink.interfaces.utility.ISmartlinkConfig"
remove="True" />
</utilities>
</componentregistry>

0 comments on commit 83a73a7

Please sign in to comment.