Updated docstring
authorThierry Florac <thierry.florac@onf.fr>
Tue, 19 Jun 2018 16:09:23 +0200
changeset 202 c3e3a8416bd7
parent 201 8953ed9beeba
child 203 0da8ef778242
Updated docstring
src/pyams_utils/factory.py
--- a/src/pyams_utils/factory.py	Tue Jun 19 11:54:53 2018 +0200
+++ b/src/pyams_utils/factory.py	Tue Jun 19 16:09:23 2018 +0200
@@ -10,6 +10,45 @@
 # FOR A PARTICULAR PURPOSE.
 #
 
+"""Objects factory management
+
+This module provides a decorator and a small set of functions to handle object factories.
+
+Instead of directly using a class as an object factory, the object of this module is to
+let you create an object based on an interface. The first step is to create an object 
+implementing this interface, and then to register it as a factory:
+
+.. code-block:: python
+
+    @implementer(IMyInterface)
+    class MyClass(object):
+        '''Class implementing my interface'''
+    
+    register_factory(IMyInterface, MyClass)
+    
+Factory registry can also be handle by a decorator called "factory_config":
+
+.. code-block:: python
+
+    @implementer(IMyInterface)
+    @factory_config(IMyInterface)
+    class MyClass(object):
+        '''Class implementing my interface'''
+
+When a factory is registered, you can look for a factory:
+
+.. code-block:: python
+
+    factory = get_object_factory(IMyInterface)
+    if factory is not None:
+        myobject = factory()
+    else:
+        myobject = MyDefaultImplementation()
+
+By registering their own objects factories, extension packages can easily provide their
+own implementation of any PyAMS interface handled by factories.
+"""
+
 __docformat__ = 'restructuredtext'