Current

This document is valid for the current version of Plone.

Component Registry

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 component registration with GenericSetup.

To register an (Zope3-like) utility local to your Plone site you can use a componentregistry.xml file in your profile.
Imagine you write an utility that connects to an external Internet video streaming service like YouTube, sending and receiving data using the API provided by them. Since you can only have a single simultaneus connection, you need an singleton utility to look up and use. Each site (you have more than one in the same instance) has its own login account, so you need to register the utility locally instead of globally.
Let's say that your utility provides the yourcompany.video.interfaces.IExternalVideo interface, and it's implemented in the yourcompany.video.ExternalVideo.ExternalVideo class. Write the following code into your componentregistry.xml file:

<?xml version="1.0"?>
<componentregistry>
  <utilities>
    <utility
      interface="yourcompany.video.interfaces.IExternalVideo"
      factory="yourcompany.video.ExternalVideo.ExternalVideo"
    />
  </utilities>
</componentregistry>

The utility will be registered upon the installation of the product.