OFS :: PropertyManager :: PropertyManager :: Class PropertyManager
[hide private]
[frames] | no frames]

Class PropertyManager



                object --+    
                         |    
       ExtensionClass.Base --+
                             |
         ZDOM.Node --+       |
                     |       |
          ZDOM.Element --+   |
                         |   |
ZDOM.ElementWithAttributes --+
                             |
                            PropertyManager
Known Subclasses:
Products.ZenRelations.ZenPropertyManager.ZenPropertyManager, Products.PageTemplates.ZopePageTemplate.ZopePageTemplate, ZenModel.ClassifierEntry.ClassifierEntry, Folder.Folder, ZenModel.ConfmonPropManager.ConfmonPropManager, ZenRelations.ZenPropertyManager.ZenPropertyManager, ZenWidgets.ZenTableManager'.ZenTableManager

The PropertyManager mixin class provides an object with transparent property management. An object which wants to have properties should inherit from PropertyManager.

An object may specify that it has one or more predefined properties, by specifying an _properties structure in its class:
 _properties=({'id':'title', 'type': 'string', 'mode': 'w'},
              {'id':'color', 'type': 'string', 'mode': 'w'},
              )

The _properties structure is a sequence of dictionaries, where each dictionary represents a predefined property. Note that if a predefined property is defined in the _properties structure, you must provide an attribute with that name in your class or instance that contains the default value of the predefined property.

Each entry in the _properties structure must have at least an 'id' and a 'type' key. The 'id' key contains the name of the property, and the 'type' key contains a string representing the object's type. The 'type' string must be one of the values: 'float', 'int', 'long', 'string', 'lines', 'text', 'date', 'tokens', 'selection', or 'multiple section'.

For 'selection' and 'multiple selection' properties, there is an addition item in the property dictionay, 'select_variable' which provides the name of a property or method which returns a list of strings from which the selection(s) can be chosen.

Each entry in the _properties structure may *optionally* provide a 'mode' key, which specifies the mutability of the property. The 'mode' string, if present, must contain 0 or more characters from the set 'w','d'.

A 'w' present in the mode string indicates that the value of the property may be changed by the user. A 'd' indicates that the user can delete the property. An empty mode string indicates that the property and its value may be shown in property listings, but that it is read-only and may not be deleted.

Entries in the _properties structure which do not have a 'mode' key are assumed to have the mode 'wd' (writeable and deleteable).

To fully support property management, including the system-provided tabs and user interfaces for working with properties, an object which inherits from PropertyManager should include the following entry in its manage_options structure:
 {'label':'Properties', 'action':'manage_propertiesForm',}
to ensure that a 'Properties' tab is displayed in its management interface. Objects that inherit from PropertyManager should also include the following entry in its __ac_permissions__ structure:
 ('Manage properties', ('manage_addProperty',
                        'manage_editProperties',
                        'manage_delProperties',
                        'manage_changeProperties',)),


Instance Methods [hide private]
 
valid_property_id(self, id)
 
hasProperty(self, id)
Return true if object has a property 'id'.
 
getProperty(self, id, d=None)
Get the property 'id'.
 
getPropertyType(self, id)
Get the type of property 'id'.
 
_wrapperCheck(self, object)
 
_setPropValue(self, id, value)
 
_delPropValue(self, id)
 
_setProperty(self, id, value, type='string')
 
_updateProperty(self, id, value)
 
_delProperty(self, id)
 
propertyIds(self)
Return a list of property ids.
 
propertyValues(self)
Return a list of actual property objects.
 
propertyItems(self)
Return a list of (id,property) tuples.
 
_propertyMap(self)
Return a tuple of mappings, giving meta-data for properties.
 
propertyMap(self)
Return a tuple of mappings, giving meta-data for properties.
 
propertyLabel(self, id)
Return a label for the given property id
 
propdict(self)
 
manage_addProperty(self, id, value, type, REQUEST=None)
Add a new property via the web.
 
manage_editProperties(self, REQUEST)
Edit object properties via the web.
 
manage_changeProperties(self, REQUEST=None, **kw)
Change existing object properties.
 
manage_changePropertyTypes(self, old_ids, props, REQUEST=None)
Replace one set of properties with another
 
manage_delProperties(self, ids=None, REQUEST=None)
Delete one or more properties specified by 'ids'.

Inherited from ExtensionClass.Base: __getattribute__, __getnewargs__, __getstate__, __new__, __reduce__, __setstate__

Inherited from object: __delattr__, __hash__, __init__, __reduce_ex__, __repr__, __setattr__, __str__

Inherited from ZDOM.ElementWithAttributes: getAttribute, getAttributeNode, getAttributes

Inherited from ZDOM.Element: getChildNodes, getElementsByTagName, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getParentNode, getPreviousSibling, getTagName

Inherited from ZDOM.Node: __providedBy__, getNodeValue, getOwnerDocument, hasChildNodes

Class Variables [hide private]
  manage_options = ({'action': 'manage_propertiesForm', 'help': ...
  manage_propertiesForm = <App.special_dtml.DTMLFile object at 0...
  manage_propertyTypeForm = <App.special_dtml.DTMLFile object at...
  title = ''
  _properties = ({'id': 'title', 'mode': 'wd', 'type': 'string'})
  _reserved_names = ()
  __ac_permissions__ = (('Manage properties', ('manage_addProper...
  __propsets__ = ()
  propertysheets = vps(DefaultPropertySheets)
  __implemented__ = <implementedBy OFS.PropertyManager.PropertyM...
  __provides__ = <zope.interface.declarations.ClassProvides obje...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

getProperty(self, id, d=None)

 

Get the property 'id'.

Returns the optional second argument or None if no such property is found.

getPropertyType(self, id)

 

Get the type of property 'id'.

Returns None if no such property exists.

propertyMap(self)

 

Return a tuple of mappings, giving meta-data for properties.

Return copies of the real definitions for security.

manage_addProperty(self, id, value, type, REQUEST=None)

 

Add a new property via the web.

Sets a new property with the given id, type, and value.

manage_editProperties(self, REQUEST)

 

Edit object properties via the web.

The purpose of this method is to change all property values, even those not listed in REQUEST; otherwise checkboxes that get turned off will be ignored. Use manage_changeProperties() instead for most situations.

manage_changeProperties(self, REQUEST=None, **kw)

 

Change existing object properties.

Change object properties by passing either a mapping object of name:value pairs {'foo':6} or passing name=value parameters

manage_changePropertyTypes(self, old_ids, props, REQUEST=None)

 

Replace one set of properties with another

Delete all properties that have ids in old_ids, then add a property for each item in props. Each item has a new_id, new_value, and new_type. The type of new_value should match new_type.

Class Variable Details [hide private]

manage_options

Value:
({'action': 'manage_propertiesForm',
  'help': ('OFSP', 'Properties.stx'),
  'label': 'Properties'})

manage_propertiesForm

Value:
DTMLFile('dtml/properties', globals(), property_extensible_schema__= 1\
)

manage_propertyTypeForm

Value:
DTMLFile('dtml/propertyType', globals())

__ac_permissions__

Value:
(('Manage properties',
  ('manage_addProperty',
   'manage_editProperties',
   'manage_delProperties',
   'manage_changeProperties',
   'manage_propertiesForm',
   'manage_propertyTypeForm',
   'manage_changePropertyTypes')),
...

__implemented__

Value:
<implementedBy OFS.PropertyManager.PropertyManager>

__provides__

Value:
<zope.interface.declarations.ClassProvides object at 0x177f7f0>