What are adapters?

(Part of ZopeInAnger)

An adapter changes the behaviour of an object - for example the FTP interface to file objects is an adapter. All FTP related stuff is implemented in the adapter (in this case it provides a size method) and the adapted interface remains blissfully unaware of FTP implementation issues.

Adapters are a major part of the ZOPE component architecture. So each component provides 'minimal' functionality by splitting out responsibilities.

Adapters usually tie objects together through the ZCML. E.g.:

<adapter
  for=".interfaces.IProject"
  provides="zope.app.filerepresentation.interfaces.IReadDirectory"
  factory=".filerepresentation.ProjectReadDirectory"
  permission="zope.View"
/>

provides IReadDirectory? functionality for an IProject? interface (indeed, to allow FTP access). For more information see the documentation.



( 97 subscribers )