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

Support for the blob News Item #2

Closed
wants to merge 53 commits into from

Conversation

Projects
None yet
@keul
Copy link
Member

commented Jun 23, 2012

Not sure if this is wanted or not by Plone (I was stuck when I found that News Items are not already using blob), however this fork add the blob support for News Item in a similar way already done for File and Image.

Mainly I added a new ATBlobContent, that differ from ATBlob for being the base for non-file-like blob contents.

keul and others added some commits May 1, 2012

removed deprecated README information; p.a.blob is now part of Plone …
…4 and the 'status' section was describing it as an alpha product
Merge pull request #3 from tomgross/master
Fixed location of temporary blobs
Fix BLOB migration when LinguaPlone is installed.
When LinguaPlone is installed, translations are updated for language
independent fields, some of which may not have been migrated yet.
Since the migrator was passing in an actual content object to the
mutator but only the ATBlob mutator could handle that and not the old
ATImage mutator, this was causing the migration to fail for individual
images that had translations.

A further side-effect of this exposes a potential ZODB bug.  When the
migration fails for an individual image, the savepoint is rolled
back.  When the transaction is then committed for those images the
transaction succeeded for a POSKeyError can happen.
removed deprecated README information; p.a.blob is now part of Plone …
…4 and the 'status' section was describing it as an alpha product
Merge branch 'master' of https://github.com/keul/plone.app.blob
Conflicts:
	src/plone/app/blob/tests/test_maintenance.py
@keul

This comment has been minimized.

Copy link
Member Author

commented Nov 25, 2012

There's also an open ticket for this: https://dev.plone.org/ticket/10123

Any plan to have also blobbed news for future Plone releases (4.3? 4.4?)

@jonstahl

This comment has been minimized.

Copy link
Member

commented Nov 25, 2012

This seems like a completely obviously good idea; probably worth having someone on the FWT sanity check esp. around migration/compatibility issues, but IMHO not needing of a full-fledged PLIP.

@pbauer

This comment has been minimized.

Copy link
Member

commented Apr 8, 2013

Note that plone.app.contenttypes has a blob-NewsItem and migration from ATNewsItem. I'll make sure that migration will also work with blobbed ATNewsItems. And: I like this, maybe it needs a mini-PLIP to be recognised by the framework-team and merged into the 4.3-series.

@jensens

This comment has been minimized.

Copy link
Member

commented May 13, 2014

This one is old. It should be merged or closed unmerged.

Its good for feature for people sticking to AT for whatever reason. But I understand also that we add more complexity to code thats in just maintenance mode (ATCT). Question is: Do we want that or can we live with the old state?

@jensens

This comment has been minimized.

Copy link
Member

commented Jun 12, 2014

I close this one because I think we need a PLIP and probably prior a discussion on the plone-dev-ML.

If there a PLIP and its synced with master and tests are running: Reopen and follow the white rabbit.

Note: this depends on #2

@jensens jensens closed this Jun 12, 2014

pbauer added a commit to plone/buildout.coredev that referenced this pull request Dec 29, 2014

Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-12-29T20:46:50+01:00
Author: Philip Bauer (pbauer) <bauer@starzel.de>
Commit: plone/plone.app.contenttypes@ddb8ad6

update docs and changes

Files changed:
M docs/CHANGES.rst
M docs/README.rst

diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst
index e8c4427..df1280d 100644
--- a/docs/CHANGES.rst
+++ b/docs/CHANGES.rst
@@ -4,11 +4,20 @@ Changelog
 1.2 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Allow migrating Topics and Subtopics to folderish Collections.
+  [pbauer]
+
+- Add migration from Topics to Collections (fixes #131).
+  [maurits, pbauer]
 
-- Consider portlets when migrating AT to DX (fixes #161)
+- Add helpers and a form to update object with changed base class. Also
+  allows migrating from itemish to folderish.
+  [bogdangi, pbauer]
+
+- Keep portlets when migrating AT to DX (fixes #161)
   [frisi, gbastien, petschki]
 
+
 1.2a5 (2014-10-23)
 ------------------
 
diff --git a/docs/README.rst b/docs/README.rst
index 883d030..0a9bddc 100644
--- a/docs/README.rst
+++ b/docs/README.rst
@@ -1,8 +1,5 @@
 .. contents::
 
-.. image:: http://jenkins.plone.org/job/kgs-plone.app.contenttypes-plone-5.0-python-2.7/badge/icon
-    :target: http://jenkins.plone.org/job/kgs-plone.app.contenttypes-plone-5.0-python-2.7/
-
 .. image:: https://pypip.in/d/plone.app.contenttypes/badge.png
     :target: https://crate.io/packages/plone.app.contenttypes
 
@@ -17,27 +14,22 @@ Introduction
 ------------
 
 
-
-plone.app.contenttypes offers default content types for Plone based on Dexterity. This package replaces ``Products.ATContenttypes`` and will provide the default-types in Plone 5.
+plone.app.contenttypes provides default content types for Plone based on Dexterity. It replaces ``Products.ATContentTypes`` and provides the default-types in Plone 5. It can be used as an add-on in Plone 4.x.
 
 It contains the following types:
 
-* Folder
+* Collection
 * Document
-* News item
+* Event
 * File
+* Folder
 * Image
 * Link
-* Event (Using behaviors from plone.app.event)
-* Collection
+* News Item
 
 The main difference from a users perspective is that these types are extendable through-the-web. This means you can add or remove fields and behaviors using the control-panel "Dexterity Content Types" (``/@@dexterity-types``).
 
-The aim is to mimick the default-types as closely as possible.
-
-plone.app.contenttypes has been merged into the Plone 5.0 branch and will be shipped with the next Plone release: https://dev.plone.org/ticket/12344
-
-**Warning: Using plone.app.contenttypes on a site with existing content requires migrating the sites content. Please see the chapter "Migration". It can be used on a new site without problems.**
+**Warning: Using plone.app.contenttypes on a site with existing Archetypes-based content requires migrating the sites content. Please see the chapter "Migration".**
 
 
 Compatibility
@@ -53,7 +45,9 @@ The versions 1.2.x of the master-branch are compatible with Plone 5 and plone.ap
 Installation
 ------------
 
-Add this line in the eggs section of your ``buildout.cfg``
+This package is included in Plone 5 and does not need installation.
+
+To use plone.app.contenttypes in Plone 4.x add this line in the eggs section of your ``buildout.cfg``
 
 .. code:: ini
 
@@ -97,29 +91,27 @@ If you install plone.app.contenttypes on a fresh site (i.e. when no content has
 Uninstalling
 ------------
 
-To remove plone.app.contenttypes and return full functionality to old content and restore the AT-based default-types you have to install the import step "Types Tool" of the current base profile. Follow the following steps:
-
-* in the ZMI navigate to portal_setup and the tab "import"
-* in "Select Profile or Snapshot" leave "Current base profile (<Name of your Plonesite>)" selected. This is usually Products.CMFPlone
-* select the Types Tool (usually Step 44)
-* click "import selected steps"
+Uninstalling the default-types is not supported in Plone 5. If you really want to switch back to Archetypes-based types you have to to the following:
 
-Any content you created based on plone.app.contenttypes will not be editable until you reinstall plone.app.contenttypes.
+* Go to the ZMI
+* In portal_types delete the default-types
+* In portal_setup navigate to the tab 'import', select the profile 'Archetypes Content Types for Plone' and install all step including dependencies.
 
+Any content you created based on plone.app.contenttypes will no longer be editable until you reinstall plone.app.contenttypes.
 
 
 Dependencies
 ------------
 
-* ``plone.app.dexterity >= 2.0.7``. Dexterity is shipped with Plone 4.3.x. Version pinns for Dexterity are included in Plone 4.2.x. For Plone 4.1.x you need to pin the correct version for Dexterity in your buildout. See `Installing Dexterity on older versions of Plone <http://developer.plone.org/reference_manuals/external/plone.app.dexterity/install.html#installing-dexterity-on-older-versions-of-plone>`_.
+* ``plone.app.dexterity >= 2.0.7``. Dexterity is shipped with Plone 4.3.x. Version pinns for Dexterity are included in Plone 4.2.x. For Plone 4.1.x you need to pin the right version for Dexterity in your buildout. See `Installing Dexterity on older versions of Plone <http://docs.plone.org/external/plone.app.dexterity/docs/install.html#installing-dexterity-on-older-versions-of-plone>`_.
 
 * ``plone.dexterity >= 2.2.1``. Olders version of plone.dexterity break the rss-views because plone.app.contenttypes uses behaviors for the richtext-fields.
 
-* ``plone.app.event >= 1.1b1``. This provides the behaviors used for the event-type.
+* ``plone.app.event >= 1.1.4``. This provides the behaviors used for the event-type.
 
 * ``plone.app.portlets >= 2.5a1``. In older version the event-portlet will not work with the new event-type.
 
-These are the version-pinns for Plone 4.3.3:
+These are the version-pinns for Plone 4.3.4:
 
 .. code:: ini
 
@@ -127,8 +119,9 @@ These are the version-pinns for Plone 4.3.3:
     versions = versions
 
     [versions]
-    plone.app.event = 1.1.1
-    plone.app.portlets = 2.5.1
+    plone.app.event = 1.1.4
+
+Plone 4.3.3 also needs ``plone.app.portlets = 2.5.2``
 
 Plone-versions before 4.3.3 need to pinn more packages:
 
@@ -156,7 +149,7 @@ For migrations to work you need at least ``Products.contentmigration = 2.1.9`` a
 Migrating Archetypes-based content to plone.app.contenttypes
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-plone.app.contenttypes can migrate the following default types:
+plone.app.contenttypes can migrate the following archetypes-based default types:
 
 * Document
 * Event
@@ -166,6 +159,7 @@ plone.app.contenttypes can migrate the following default types:
 * Link
 * News Item
 * Collection
+* Topic (old Collections)
 
 The following non-default types will also be migrated:
 
@@ -174,13 +168,39 @@ The following non-default types will also be migrated:
 * The Event-type provided by plone.app.contenttypes until version 1.0
 * News Items with blobs (provoded by plone/plone.app.blob#2)
 * Files and Images without blobs
-* AT-based collection provided by plone.app.collection
 
-Migrations that are coming in future versions:
 
-* from ATTopic to Collections
+Migrating Topics
+^^^^^^^^^^^^^^^^
+
+Topics are migrated to Collections. However, the old type Topic had support for Subtopics, a feature that does not exit in Collections. Subtopics are nested Topics that inherited search terms from their parents. Since Collections are not folderish (i.e. they cannot contain content) Subtopics cannot be migrated unless Collections are made folderish (i.e. that they can contain content). Also the feature that search terms can be inherited from parents does not exist for Collections.
+
+The migration-form will warn you if you have subtopics in your site and your Collections are not folderish. You then have several options:
+
+1. You can delete all Subtopics before migrating and achieve their functionality in another way (e.g. using eea.facetednavigation).
+2. You can choose to not migrate Topics by not selecting them. This will keep your old Topics functional. You can still add new Collections.
+3. You can modify Collections to be folderish or create your own folderish content-type.   That type would need a base-class that inherits from ``plone.dexterity.content.Container`` instead of ``plone.dexterity.content.Item``:
+
+   .. code-block:: python
+
+      from plone.app.contenttypes.behaviors.collection import ICollection
+      from plone.dexterity.content import Container
+      from zope.interface import implementer
 
-Please note that migrating versions of content is not supported. Only the current state of items is migrated without any content- or workflow-history.
+      @Implementer(ICollection)
+      class FolderishCollection(Container):
+          pass
+
+   You can either use a new Collection type or simply modify the default type to use this new base-class by overriding the klass-attribute of the default Collection. To override add a ``Collection.xml`` in your own package:
+
+   .. code-block:: xml
+
+      <?xml version="1.0"?>
+      <object name="Collection" meta_type="Dexterity FTI">
+       <property name="klass">my.package.content.FolderishCollection</property>
+      </object>
+
+   If you really need it you could add the functionality to inherit search terms to your own folderish Collections by extending the behavior like in the example at plone/plone.app.contenttypes@366cc1a
 
 
 Migrating content that is translated with LinguaPlone
@@ -213,9 +233,9 @@ Migrating custom content
 
 Custom content-types will not be touched by the migration plone.app.contenttypes and will continue to work as expected.
 
-Future versions of plone.app.contenttypes will have with a form that allows you to migrate old custom Archetypes-content to Dexterity (you'll have to create the Dexterity-types before) .
+Future versions of plone.app.contenttypes will have with a form that allows you to migrate old custom Archetypes-content to Dexterity (you'll still have to create the Dexterity-types before migrating).
 
-However if you'd like to migrate your content-types to Dexterity before this feature is completed you might want to have a look at the code of plone.app.contenttypes.migration.migration.NewsItemMigrator as a blueprint for a migration.
+If you want to migrate your custom types to Dexterity before this feature is completed you might want to have a look at the code of plone.app.contenttypes.migration.migration.NewsItemMigrator as a blueprint for a migration.
 
 
 Widgets
@@ -457,4 +477,5 @@ Contributors
 * David Glick <david@glicksoftware.com>
 * Kees Hink <keeshink@gmail.com>
 * Roman Kozlovskyi <krzroman@gmail.com>
-
+* Bogdan Girman <bogdan.girman@gmail.com>
+* Martin Opstad Reistadbakk <martin@blaastolen.com>

pbauer added a commit to plone/buildout.coredev that referenced this pull request Dec 31, 2014

Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2014-12-31T16:20:33+01:00
Author: Philip Bauer (pbauer) <bauer@starzel.de>
Commit: plone/plone.app.contenttypes@16db5e5

add documentation on features that are not migrated and on pac_installer

Files changed:
M docs/README.rst

diff --git a/docs/README.rst b/docs/README.rst
index 0a9bddc..09dcd92 100644
--- a/docs/README.rst
+++ b/docs/README.rst
@@ -137,14 +137,14 @@ Plone-versions before 4.3.3 need to pinn more packages:
     plone.app.event = 1.1b1
     plone.app.portlets = 2.5.1
 
+For migrations to work you need at least ``Products.contentmigration = 2.1.9`` and ``plone.app.intid`` (part of Plone since Plone 4.1.0).
+
 
 Migration
 ---------
 
 To migrate your existing content from Archetypes to Dexterity use the form at ``/@@atct_migrator``.
 
-For migrations to work you need at least ``Products.contentmigration = 2.1.9`` and ``plone.app.intid`` (part of Plone since Plone 4.1.0).
-
 
 Migrating Archetypes-based content to plone.app.contenttypes
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -169,6 +169,18 @@ The following non-default types will also be migrated:
 * News Items with blobs (provoded by plone/plone.app.blob#2)
 * Files and Images without blobs
 
+The migration tries to keep most features (including portlets, comments and local roles). The following features are **not** migrated:
+
+* **Content-rules:** Rules assigned to content are not migrated. Rules assigned at the site itself are kept.
+* **Local workflows:** Workflows-assignments to content using CMFPlacefulWorkflow are not migrated.
+* **Versions:** During migration you will lose all old revisions.
+
+
+Migrating only certain types
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+There is also a view ``/@@pac_installer`` that allows you to install plone.app.contenttypes without replacing those archetypes-types with the dexterity-types of which there are existing objects in the site. Afterwards it redirects to the migration-form and only the types that you chose to migrate are installed. This allows you to keep certain types as archetypes while migrating others to dexterity (for example if you did heavy customizations of these types and do not have the time to reimplement these features in dexterity.
+
 
 Migrating Topics
 ^^^^^^^^^^^^^^^^

pbauer added a commit to plone/buildout.coredev that referenced this pull request Jan 1, 2015

Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2015-01-01T13:24:26+01:00
Author: Philip Bauer (pbauer) <bauer@starzel.de>
Commit: plone/plone.app.contenttypes@4c624f3

fix docs (placeful workflows are migrated)

Files changed:
M docs/README.rst

diff --git a/docs/README.rst b/docs/README.rst
index 09dcd92..6c4c98d 100644
--- a/docs/README.rst
+++ b/docs/README.rst
@@ -169,11 +169,10 @@ The following non-default types will also be migrated:
 * News Items with blobs (provoded by plone/plone.app.blob#2)
 * Files and Images without blobs
 
-The migration tries to keep most features (including portlets, comments and local roles). The following features are **not** migrated:
+The migration tries to keep most features (including portlets, comments, local roles and local workflows). The following features are **not** migrated:
 
-* **Content-rules:** Rules assigned to content are not migrated. Rules assigned at the site itself are kept.
-* **Local workflows:** Workflows-assignments to content using CMFPlacefulWorkflow are not migrated.
 * **Versions:** During migration you will lose all old revisions.
+* **Content-rules:** Rules assigned to content are not migrated. Rules assigned at the site itself are kept.
 
 
 Migrating only certain types

pbauer added a commit to plone/buildout.coredev that referenced this pull request Jan 1, 2015

Repository: plone.app.contenttypes
Branch: refs/heads/master
Date: 2015-01-01T21:23:18+01:00
Author: Philip Bauer (pbauer) <bauer@starzel.de>
Commit: plone/plone.app.contenttypes@96d3d06

add migration for contentrules

Files changed:
M docs/README.rst
M plone/app/contenttypes/migration/migration.py
M plone/app/contenttypes/migration/utils.py

diff --git a/docs/README.rst b/docs/README.rst
index 6c4c98d..56b4bdb 100644
--- a/docs/README.rst
+++ b/docs/README.rst
@@ -169,10 +169,9 @@ The following non-default types will also be migrated:
 * News Items with blobs (provoded by plone/plone.app.blob#2)
 * Files and Images without blobs
 
-The migration tries to keep most features (including portlets, comments, local roles and local workflows). The following features are **not** migrated:
+The migration tries to keep most features (including portlets, comments, contentrules, local roles and local workflows).
 
-* **Versions:** During migration you will lose all old revisions.
-* **Content-rules:** Rules assigned to content are not migrated. Rules assigned at the site itself are kept.
+**Warning:** Versions of content are not migrated. During migration you will lose all old revisions.
 
 
 Migrating only certain types
diff --git a/plone/app/contenttypes/migration/migration.py b/plone/app/contenttypes/migration/migration.py
index 78b2d51..4d23a87 100644
--- a/plone/app/contenttypes/migration/migration.py
+++ b/plone/app/contenttypes/migration/migration.py
@@ -21,6 +21,7 @@
 from plone.app.contenttypes.migration.dxmigration import DXEventMigrator
 from plone.app.contenttypes.migration.dxmigration import DXOldEventMigrator
 from plone.app.contenttypes.migration.utils import add_portlet
+from plone.app.contenttypes.migration.utils import copy_contentrules
 from plone.app.contenttypes.migration.utils import move_comments
 from plone.app.textfield.value import RichTextValue
 from plone.app.uuid.utils import uuidToObject
@@ -41,8 +42,8 @@
 from zope.interface import Interface
 from zope.interface import implementer
 from zope.intid.interfaces import IIntIds
-import logging
 
+import logging
 logger = logging.getLogger(__name__)
 
 
@@ -292,6 +293,9 @@ def migrate_custom(self):
     def migrate_portlets(self):
         migrate_portlets(self.old, self.new)
 
+    def migrate_contentrules(self):
+        copy_contentrules(self.old, self.new)
+
     def last_migrate_comments(self):
         """Migrate the plone.app.discussion comments.
            Comments were stored on the portal, get them and
@@ -322,6 +326,9 @@ def migrate_custom(self):
     def migrate_portlets(self):
         migrate_portlets(self.old, self.new)
 
+    def migrate_contentrules(self):
+        copy_contentrules(self.old, self.new)
+
 
 class DocumentMigrator(ATCTContentMigrator):
 
diff --git a/plone/app/contenttypes/migration/utils.py b/plone/app/contenttypes/migration/utils.py
index 609b543..35073bb 100644
--- a/plone/app/contenttypes/migration/utils.py
+++ b/plone/app/contenttypes/migration/utils.py
@@ -7,9 +7,11 @@
 from archetypes.schemaextender.interfaces import ISchemaExtender
 from archetypes.schemaextender.interfaces import ISchemaModifier
 from copy import deepcopy
+from plone.app.contentrules.api import assign_rule
 from plone.app.contenttypes.utils import DEFAULT_TYPES
-from plone.app.discussion.conversation import ANNOTATION_KEY
+from plone.app.discussion.conversation import ANNOTATION_KEY as DISCUSSION_KEY
 from plone.app.discussion.interfaces import IConversation
+from plone.contentrules.engine.interfaces import IRuleAssignmentManager
 from plone.dexterity.interfaces import IDexterityFTI
 from plone.portlets.interfaces import IPortletAssignmentMapping
 from plone.portlets.interfaces import IPortletManager
@@ -129,14 +131,28 @@ def move_comments(source_object, target_object):
     and then removing the comments from the source (not the annotation).
     """
     source_annotations = IAnnotations(source_object)
-    comments = source_annotations.get(ANNOTATION_KEY, None)
+    comments = source_annotations.get(DISCUSSION_KEY, None)
     if comments is not None:
         target_annotations = IAnnotations(target_object)
-        if target_annotations.get(ANNOTATION_KEY, None) is not None:
+        if target_annotations.get(DISCUSSION_KEY, None) is not None:
             logger.error('Comments exist on {0}').format(
                 target_object.absolute_url())
-        target_annotations[ANNOTATION_KEY] = deepcopy(comments)
+        target_annotations[DISCUSSION_KEY] = deepcopy(comments)
         source_conversation = IConversation(source_object)
         for comment in source_conversation.getComments():
             del source_conversation[comment.comment_id]
-        del source_annotations[ANNOTATION_KEY]
+        del source_annotations[DISCUSSION_KEY]
+
+def copy_contentrules(source_object, target_object):
+    """Copy contentrules.
+    """
+    source_assignable = IRuleAssignmentManager(source_object, None)
+    if source_assignable is not None:
+        try:
+            IRuleAssignmentManager(target_object)
+        except TypeError:
+            logger.info("Cound not migrate contentrule to {0}".format(
+                target_object.absolute_url()))
+            return
+        for rule_id in source_assignable:
+            assign_rule(target_object, rule_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.