Current

This document is valid for the current version of Plone.

Properties

by Plone Documentation Team last modified Dec 27, 2009 05:45 PM
Contributors: Mikko Ohtamma, Martin Aspeli, Kamon Ayeva, Israel Saeta Pérez
Information about the import and export of property sheets.

GenericSetup exports two kinds of property files by default. The properties.xml contains the properties set at the root of your Plone site. The propertiestool.xml contains all of the property sheets that are in the properties_tool. Both of these use the same syntax that will be described here. See the Properties Reference for more detailed information about what these properties do.

The propertiestool.xml is split into a section for each property sheet.

<?xml version="1.0"?>
<object name="portal_properties" meta_type="Plone Properties Tool">
 <object name="navtree_properties" meta_type="Plone Property Sheet">
   <!-- nav properties here -->
 </object>

 <object name="site_properties" meta_type="Plone Property Sheet">
   <!-- site properties here -->
 </object>

 <object name="custom_property_sheet" meta_type="Plone Property Sheet">
   <property name="title" type="string">Custom Properties</property>
   
   <!-- custom_property_sheet props here -->
 </object>
</object>

The property export handles all of the property sheet types. Single value properties are in the following format.

<property name="property_id" type="property_type">property_value</property>

Where the property_id is the id that the property will have in the property sheet and the property_value is the value that the property gets set to. Here are a couple of examples.

<property name="special_name" type="string">This is special</property>
<property name="magic_number" type="int">3</property>

However, there are a couple of exceptions to this behavior.

Boolean

Boolean properties can be set as follows:

<property name="has_truth" type="boolean">true</property>
<property name="has_truth" type="boolean">True</property>
<property name="has_truth" type="boolean">TRUE</property>
<property name="has_truth" type="boolean">Yes</property>
<property name="has_truth" type="boolean">1</property>

The values True, Yes and 1 will end up being true, these are case insensitive. Any other value will be taken as False.

<property name="has_truth" type="boolean">anything besides true yes or 1 here</property>

Lines

Multi valued properties are known as lines properties. Here is an example of a grocery_list property with three values.

<property name="grocery_list" type="lines">
  <element value="beer"/>
  <element value="chips"/>
  <element value="salsa"/>
</property>

Each <element> will become an item in the lines property.

If you want to update existing lines properties then you need to understand the purge option. If you want to add to the list then you will put purge="false" as follows:

<property name="grocery_list" type="lines" purge="false">
  <element value="wine"/>
  <element value="steak"/>
</property>

Now the property will contain the following:

beer
chips
salsa
wine
steak

If the purge option is not explicitly set (it defaults to true) or if it is set to true, then you would get this:

wine
steak

Date

A date property is similar to the string property but interprets the value as a DateTime.

<property name="day_of_infamy" type="date">December 7, 1941</property>