Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tips / Transmogrifier

Transmogrifier

內容型別的資料移植,通常有三種方式,一是將內容匯出成檔案再匯入,二是利用 JSON 資料來移植,三是利用 Funnelweb 來移植。

Plone 4.x 移植到 Plone 5.x 的建議流程: 順序上,目錄要先建立,內含項目才能移植成功。獨立於 Plone 環境 (不需要 CMFCore)

eggs +=
    psycopg2
    argparse
    collective.transmogrifier
    plone.app.transmogrifier
    transmogrify.sqlalchemy

以 Plone 4.0.2 為例,安裝 psycopg2 (2.2.2) collective.transmogrifier (1.2) plone.app.transmogrifier (1.1) transmogrify.sqlalchemy (1.0.1) SQLAlchemy (0.6.5)

以 Plone 4.0.7 為例,已內建 distribute 0.6.16 不需要在 buildout.cfg 指定,SQLAlchemy (0.7.1) collective.transmogrifier (1.3) psycopg2 (2.4.2)

依照 CSV 內容批次建立項目

source 支援的格式包括 CSV, SQL database 等,輸出的格式包括 plone.rfc822, z3c.schema2xml

path 使用 ASCII 編碼 UnicodeDecodeError

Default Page Name Assumption

Append Data to a Field Deserializer for DateTime Field

transmogrify.dexterity: CSV Import Pipeline, Prevent value-converters from failing for non-intids

協助開發過程的測試工作,利用 curl 工具,還可以把 ZMI 介面操作的步驟自動化。

transmogrify.ploneremote getPhysicalPath 缺 DocString

transmogrify.filesystem: Hints to Migrate News Items with Image Fields

transmogrify.command

niteoweb.transmogrifier.simpleusage

transmogrify.htmlcontentextractor funnelweb

SixFeet Up Blog Migrating from Drupal: github code

wordpress2plone transmogrify.wordpress

my.migration
├── my
│   ├── __init__.py
│   └── migration
│       ├── __init__.py
│       └── migration
│           ├── __init__.py
│           ├── config
│           │   ├── articles.cfg
│           │   ├── base.cfg
│           │   ├── blogs.cfg
│           │   ├── comments.cfg
│           │   └── pages.cfg
│           ├── configure.zcml
│           └── profiles
│               └── default
│                   ├── metadata.xml
│                   └── transmogrifier.txt
├── setup.cfg
└── setup.py

dexterity: look up an FTI for a portal type via queryUtility(IDexterityFTI, name=portal_type), and then get its schema via lookupSchema(), use that to figure out which fields to set (e.g. using setattr).

collective.jsonify collective.jsonmigrator

當系統過舊、無法安裝 transmogrify 可借助 collective.jsonifycollective.jsonmigrator。要先確認 simplejson 是否已經安裝:

$ bin/zopepy
>>> import simplejson
ImportError: No module named simplejson

把 collective.jsonify 安裝在來源網站,建立 <INSTANCE>/parts/instance/Extensions/json_methods.py 內容如下:

from collective.jsonify import get_item
from collective.jsonify import get_children

建立兩個 External Method 對應:

Id: get_item
Method Name: json_methods
Function Name: get_item

把 collective.jsonmigrator 安裝在目的網站,從 /@@jsonmigrator 進入管理介面。必要的話,編輯 collective/jsonmigrator/<pipeline-name>.cfg 內容。通常也要重新執行 Catalog Build。

Development with transmogrify.dexterity

transmogrify.siteanalyser

Funnelweb

Funnelweb 需要提供 XPaths 給欄位: collections.OrderedDict ties to Python 2.7 example by Asko Soukka

Command Example existing folder file structure

$ bin/funnelweb
  --crawler:url=http://wiki.scandiatransplant.com
  --crawler:max=50
  --ploneupload:target=http://admin:admin@localhost:8080/TestPage

funnelweb: transmogrify.siteanalyser bug funnelweb.ttw example

Version 1.5 Workaround: adding auto-checkout += collective.transmogrifier (with mr.developer)

quintagroup.transmogrifier

quintagroup.transmogrifier not aware of plone.app.discussion

pipeline processing issue

[marshaller]
blueprint = quintagroup.transmogrifier.marshaller
exclude =
    immediatelyAddableTypes
    locallyAllowedTypes

The set method in DataGridField expects a "value" parameter which is a list of dictionaries containing the grid fields.

利用 quintagroup.transmogrifier 來移植目錄資料,範例包括 simpleblog2quills

Content can be export/import directly to the FileSystem instead of building a "tar.gz" export using quintagroup.transmogrifier "context" attribute of the [reader] section.

plone-static-export.py

Archetypes 與 Dexterity 對應

Accessor 與 Mutator

UUID

from plone.uuid.interfaces import ATTRIBUTE_NAME

setattr(obj, ATTRIBUTE_NAME, uuid)