Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Tips / Archetypes Migration

Archetypes Migration

透過 @@atct_migrator 和 @@custom_migration 可以昇級 Archetypes 成為 Dexterity

要先安裝 Products.contentmigration 才能確保 plone.app.contenttypes 的 migration 模組生效,透過 [migrate_atct] 參數可以選定安裝,不過在 Changelog 提及已被移除。

如果 var/blobstorage/0x00 不見的話,會遇到 SystemError: error return without exception set 錯誤。

  Module plone.app.blob.field, line 321, in get_size
  Module plone.app.blob.field, line 129, in get_size
  Module plone.app.blob.utils, line 52, in openBlob
SystemError: error return without exception set

ATCT Migration

執行 @@atct_migrator 後,Collection of Events 會產生下列錯誤:

plone.app.contenttypes/browser/templates/listing.pt Line 57, Column 26
Expression: <PythonExpr (view.formatted_date(obj))>
AttributeError: 'NoneType' object has no attribute 'date'

個別 Event 頁面會產生下列錯誤,在 plone.app.event 新版裡已處理,純粹是昇級問題,建立新的 Event 也會正常:

plone.app.event/browser/event_view.pt Line 19, Column 6
Expression: <PathExpr standard:u'data/start/isoformat'>
LocationError: (None, 'isoformat')

個別處理的方法是 item.timezone = 'Asia/Taipei' 就行。

Collection 要事先額外執行昇級工作,不然會遇到 AttributeError: @@at_base_edit_view 問題,即使事後安裝 plone.app.collection = 1.1.2 也沒用。

Plone 4.3.12 在 develop.cfg [versions] plone.app.collection = 1.1.2 會多裝 plone.app.widgets 1.8.0

因為 Products.ZCatalog 不帶參數的情況下無法取得所有 brain 要改用 catalog_get_all() Helper Method 來讀取資料。

FIELDS_MAPPING

RichText, Image, File 使用特別的昇級工具

Custom Migration

migration/migration.py 裡 migrateCustomAT() 利用 archetype_tool 的 meta_type 來確認,因為 portal_types 可能使用相同 meta_type,另外附有 dry_run 參數。

Custom Type SchemaExtender

舊的 Archetypes 模組啟用情況下,新的 Dexterity 想要同時啟用,可能會遇到 ValueError: undefined property 'add_permission' 之類的錯誤,先把 Archetype 模組停用,再啟用 Dexterity 模組,最後執行 @@custom_migration 就行。有人在 custom_migration.py 加上 try/except 來檢查,通常是 ATBTreeFolder 造成問題,從 portal_catalog/Indexes/meta_type 可以查看情況,另有 cpskin.migration 經驗記錄