collective / collective/collective.exportimport
Add modifiers to simplify handling migrations
- Dominant language
- Python
- Stars
- 19
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
Some changes need to be done to the serialized data when this tool is used for a migration (e.g. from Plone 4 to Plone 5 or 6) and/or from Archetypes to Dexterity.
To make this easier we could add a checkbox (checked by default) "Modify data for migrations".
If this is checked then some modifiers will run during export.
These could include:
### Drop unused data
Some data that restapi includes is useless for migrations. E.g. `@components`, `next_item`, `previous_item`.
### Drop all Relations
Relations are migrated seperately. haveing them in the data will mess up the site. This is probably easiest done by switching on custom serializers for `IReferenceField` (AT) and `IRelationChoice` and `IRelationList` (DX) that return none.
### Change default-fieldnames (AT to DX):
```python
# Migrate AT to DX
if item.get("expirationDate"):
item["expires"] = item["expirationDate"]
if item.get("effectiveDate"):
item["effective"] = item["effectiveDate"]
if item.get("excludeFromNav"):
item["exclude_from_nav"] = item["excludeFromNav"]
if item.get("subject"):
item["subjects"] = item["subject"]
```
### Fix datetime data
see #10
### Fix issue with AT Text fields
TextField-export in Archetypes: Inspecting the AT-schema and applying a change for all Textfields if the RichtextWidget is not used (which means the field is probably Text in DX and not RichText).
```
# In Archetypes Text is handled the same as RichText
if isinstance(item.get("description", None), dict):
item[fieldname] = item[fieldname]["data"]
if isinstance(item.get('rights', None), dict):
item['rights'] = item['rights']['data']
```
### Fix collection-criteria
Some criteria have changed, e.g.
``` python
query = item.pop("query", [])
for crit in query:
if crit["o"].endswith("relativePath") and crit["v"] == "..":
crit["v"] = "..::1"
if crit["i"] == "portal_type" and crit["o"].endswith("selection.is"):
crit["o"] = "plone.app.querystring.operation.selection.any"
```
### Fix image links and scales
Use the code in https://github.com/collective/collective.migrationhelpers/blob/master/src/collective/migrationhelpers/images.py to fix links to images and make them editable in TinyMCE.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the migration modifier categories in this issue, the datetime work referenced by #10, and the image-handling code in collective.migrationhelpers/images.py. Determine how the proposed checkbox and each modifier fit the export flow; done means the migration-specific transformations are defined and covered for the listed cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100