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

Adapters

Adapters could be considered the glue components of the Zope architecture because they connect one interface with another and allow various advanced programming techniques, such as aspect-oriented programming. An adapter uses a component implementing one interface to provide another interface.

This allows the developer to split up the functionality into small API pieces and keep the functionality manageable. For example, you could write an adapter that allows an IExample content component to be represented as a file in FTP (see Figure 7.2). This can be done by implementing the IReadFile and IWriteFile interface for the content component. Instead of adding this functionality directly to the SimpleExample class by implementing the interfaces in the class, you can create an adapter that adapts IExample to IReadFile and IWriteFile. An adapter can be registered programmatically, but the more common use is to use the ZCML adapter directive. When the adapter is registered for both interfaces (usually through ZCML), it can be used as follows:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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