How to install ftw.inflator
- Download and install ActivePython
- Open Command Prompt
pypm install ftw.inflator
This packages helps predefining a Plone site setup including content creation (using generic setup), defining multiple bundles and a wizard for installing a new site with a bundle.
Table of Contents
- Setup wizard
- Bundle system
- Content creation
- A simplified site setup wizard. The wizard can be customized and branded.
- A bundle system for defining variants in the setup configuration.
- A generic setup site creation import step which can be used in the bundles for creating initial content. It can be used without using the setup wizard and bundle system.
- Add ftw.inflator to your buildout configuration:
On the manage_main view of the Zope app there is an additional button for installing your product. It leads to the site setup wizard where an ID and a bundle can be selected.
The setup wizard allows to select one of a set of predefined bundles. See the bundle section for details on how to define bundles.
The product name and logo can easily be customized through ZCML:
A bundle defines a list of profiles which are automatically applied when creating a new Plone site with this bundle.
It has a base-profile (defaults to the Plone default base profile without default content).
The bundles are defined in ZCML:
- The (translatable) title of the bundle, shown in the setup wizard.
- One or multiple Generic Setup profiles (without profile--prefix).
- description (optional)
- The description of the bundle, shown in the setup wizard.
- base (optional)
- The Generic Setup base profile for creating the plone site. This defaults to Products.CMFPlone:plone, the default plone base profile without content creation. Using Products.CMFPlone:plone-content will generate the default example content.
- standard (optional)
- By using the standard flag (standard="True") you can define product bundles. When registering custom bundles later without flagging them as standard, they will appear above the standard bundles in the setup wizard and top is selected.
Full ZCML example:
When installing a Plone site with the default add-site view, the language is set in the Products.CMFPlone:plone-content, which also creates example content. This makes it hard to setup the language without creating the example content.
To solve this issue ftw.inflator provides a ftw.inflator:setup-language generic setup profile, meant to be used while setting up a bundle. You can add it to the list of bundle profiles. This sets the language of the Plone site to the one selected in the setup wizard. Using it as a dependency (in metadata.xml) is not recommended, since it is not meant to be used on a existing plone site.
Example usage in bundle definition:
The content creation allows to define a content_creation folder in any generic setup profile folder, containing JSON-files with definitions of the content to create. The content is created when the generic setup profile is applied.
- JSON based definition
- support for tree structure
- internationalization of strings
- construct instances of any archetypes FTIs
- add file- and image-fields
- create topic criterions
- execute workflow transition on creation
- create placeful workflow policies
- set properties
- set constraint types
- set per-object provided interfaces
- reindexing the catalog
Add a content_creation folder to your generic setup profile. All content creation configurations are within this folder. You can add as many *.json-files as you want - they will be read and executed in order of the sorted filename (use integer prefixes for sorting them easily).
For creating content create a JSON file ( e.g. profiles/default/content_creation/01-foo-folder.json) and insert a JSON syntax list of hashes (dicts). Each hash creates a new object. Example creating a folder with title "Foo" at /Plone/foo:
For nested structures it sometimes useful to define the JSON as tree. Using the tree structure it is not necessary to repeat the path of the parent:
Be sure that the root node has a _path and all nodes in a _children list have _id instead of _path. The path will then be automatically concatenated.
Using the key:translate(domain) syntax in keys, the respective string value is translated to the current default language of the Plone site. When creating content while installing a bundle with inflator, be sure to install the generic setup profile ftw.inflator:setup-language before creating the content. This will make sure the language is properly configured.
Properties can easily be created. If there already is a property (because the object exists already), it is updated.
For configuring the addable types on a folder, use the _constrain_types keyword:
By passing a list of dottednames as _interfaces those interfaces will automatically be provided (alsoProvides) by the created object:
By prefixing the dotted name with remove:, directly provided interfaces can be removed (noLongerProvides).
File- and image-fields can easily be filled by using the :file postfix, providing a relative path to the file to "upload":
With the _transitions keyword it is possible to execute a workflow transition upon content creation:
When placeful workflow policies are installed it is possible to activate them on a folder using the _placefulworkflow keyword:
You need to install the Generic Setup profile Products.CMFPlacefulWorkflow:CMFPlacefulWorkflow for using placeful workflow policies.
With the _annotations it is possible to set simple annotations on the object. Values of type dict are converted to PersistentMapping, those of type list are converted to PersistentList recursively. Example:
Sometimes you need to have the UUID of another object. Since the UUID is generated randomly when creating the object you cannot predict it in a .json-file. The UUID lookup helps you here:
Using the resolveUUID::path syntax the value is replaced with UUID of the object which has the path. You can prefix the value with a / for making it relative to the site root, otherwise it is relative to the item it is defined in ("Foo" in the above example).
- Make sure that the Products.CMFPlone ZMI patches are applied prior to our patches. [jone]
- Support UTF-8 encoded strings as value for :translate(). [treinhard]
- Implement UUID lookup. [jone]
- Add Dexterity support to content creation. Use the ftw.inflator[dexterity] extras. [jone]
- Run content creation after type creation. [jone]
- Move site creation into bundle class, so that a site with a bundle can be created without using the view. This is useful for tests or automated setups. [jone]
- Support internationalization with key:translate(domain) key syntax. [jone]
- Add support for nested tree structures. [jone]
- Fix bad page template expression. [jone]
- Initial implementation. [jone]