GenericSetup
Plone2.5以降では、プロダクトのインストールにGenericSetupという仕組みが使われているようです。ドキュメントをザッと読んでみたので、内容をメモしておきたいと思います。
Understanding and Using GenericSetup in Plone
プロファイルってなに?
プロファイルの実行について
- プロダクトをインストールすると、基本プロファイルのimport-steps.xmlに記述されている、import-step要素が順次実行されます。
- 各ステップの設定ファイルの名前は、
.xml です。 - 各ステップを実際に実行するのは、import-step要素のhandler属性で指定されているcallableです。
- ハンドラの中には、プロファイルに、特定のファイルが存在するかどうかを調べて実行するものがあります。どのファイルをチェックするかは、ハンドラの実装に依存します。
- たとえば、Ploneサイトのデフォルト・コンテンツを作成する、plone-contentステップのハンドラは、プロファイルの中にplone-content.txtというファイルが存在する場合だけ実行するように実装されています。
- っていうか、こういうことなんでしょうね。おそらく。
- hogehoge.xmlを読み込んで設定するタイプのハンドラは、設定ファイルがなければ何にもしない。
- 設定いらずで何かやっちゃう系のハンドラは、fugafuga.txtが動いていいよスイッチになってる。
プロファイルの登録
MyProductディレクトリ直下のconfigure.zcmlに、次のようなディレクティブを記述します。プロファイルの内容は、MyProduct/profiles/defaultに格納します。
<configure xmlns="http://namespaces.zope.org/zope" xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="MyProduct" > <genericsetup:registerProfile name="default" title="MyProduct" description="Extension profile for MyProduct." directory="profiles/default" provides="Products.GenericSetup.interfaces.EXTENSION" for="Products.CMFPlone.interfaces.IPloneSiteRoot" /> </configure>
registerProfileディレクティブには、次の属性があります。
- name
- 必須
- title
- 必須
- description
- 必須
- directory
- オプション。デフォルトは "profiles/{$name}"
- 登録するプロファイルを格納するディレクトリ
- provides
- オプション。デフォルトは"BASE"
- for
- オプション。デフォルトはNone
プロファイルの内容
profiles/defaultディレクトリの内容は次のようになります。
どうも基本的に各XMLファイルが、個別のportalツールの設定になっているようです。
各xmlファイルの書き方は、Products/CMFPlone/profiles/default を参考にすると、大体分かります。
- factorytools.xml
- types.xml
- portal_typesツールで定義する、コンテンツ・タイプのリストを記述します。
- types(ディレクトリ)
- skins.xml
- skins(ディレクトリ)
- skins.xmlにリストアップされた、各スキン・レイヤのフォルダを格納します。
- cssregistry.xml
- jssregistry.xml
- スキン・レイヤに配置したJavaScriptファイルを、portal_cssツールに登録する時に使います。
- catalog.xml
- コンテンツのカタログ設定をしたい時だけ作ります。
- archetype_tool.xml
- どのツールにカタログするかを指定する時に使います。
- その他の使い方もあるかも知れませんが、よく分かりません。
- rolemap.xml
- カスタムパーミッション、ロールの定義に使います。
- 詳しくはこちらを:Adding a custom permission to a product
ーworkflow.xml
ーworkflow(ディレクトリ)
-
- 個別のワークフローの定義を格納します。
factorytools.xml
<?xml version="1.0"?> <object name="portal_factory" meta_type="Plone Factory Tool"> <factorytypes> <type portal_type="ContentTypeA"/> <type portal_type="ContentTypeB"/> </factorytypes> </object>
types.xml
<?xml version="1.0"?> <object name="portal_types" meta_type="Plone Types Tool"> <property name="title"> Controls the available content types in your portal </property> <object name="ContentTypeA" meta_type="Factory-based Type Information with dynamic views"/> <object name="ContentTypeB" meta_type="Factory-based Type Information with dynamic views"/> </object>
types(ディレクトリ)
skins.xml
catalog.xml
次のコードは、portal_catalogに、3つのインデックス(getPersonId, getFullname, getEmail)を作成する例です。インデックスのタイプ(FieldIndexとかZCTextIndexとか)はmeta_type属性で指定します。
<?xml version="1.0"?> <object name="portal_catalog" meta_type="Plone Catalog Tool"> <object name="plone_lexicon" meta_type="ZCTextIndex Lexicon"> <element name="Unicode Whitespace splitter" group="Word Splitter"/> <element name="Unicode Case Normalizer" group="Case Normalizer"/> </object> <index name="getPersonId" meta_type="FieldIndex"> <indexed_attr value="getPersonId"/> </index> <index name="getFullname" meta_type="ZCTextIndex"> <indexed_attr value="getFullname"/> <extra name="index_type" value="Cosine Measure"/> <extra name="lexicon_id" value="plone_lexicon"/> </index> <index name="getEmail" meta_type="FieldIndex"> <indexed_attr value="getEmail"/> </index> <column value="getPersonId"/> <column value="getFullname"/> <column value="getEmail"/> </object>
archetype_tool.xml
次のコードでは、SampleMemberは、portal_catalogとmembrane_toolの両方にカタログされますが、Hogeはportal_catalogにしかカタログされません。
<?xml version="1.0"?> <archetypetool> <catalogmap> <type portal_type="SampleMember"> <catalog value="portal_catalog"/> <catalog value="membrane_tool"/> </type> <type portal_type="Hoge"> <catalog value="portal_catalog"/> </type> </catalogmap> </archetypetool>
workflow.xml
<?xml version="1.0"?> <object name="portal_workflow" meta_type="Plone Workflow Tool"> <object name="my_workflow" meta_type="Workflow"/> <bindings> <type type_id="MyContent"> <bound-workflow workflow_id="qms_workflow"/> </type> </bindings> </object>