• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. The Component Architecture: A... > Factories (Object Classes/Prototypes...

Factories (Object Classes/Prototypes)

Factories, as the name suggests, exist merely to create other components and objects. Factories can be methods, classes, or even instances that are callable. You encounter them directly only when dealing with content objects (because ZCML creates factories for you automatically) if you specify the factory directive. The functionality and usefulness of factories is best described by an example.

Let's consider the SimpleExample content component once more. A factory has to provide two methods. The obvious one is the __call__() method, which creates and returns a SimpleExample instance. The second method, called getInterfaces(), returns a list of interfaces that the object created by calling __call__ will provide.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint