The PEAK Developers' Center   WritingAdaptors UserPreferences
 
HelpContents Search Diffs Info Edit Subscribe XML Print View
The following 91 words could not be found in the dictionary of 50 words (including 50 LocalSpellingWords) and are highlighted below:
Adapting   Adaptors   Edible   Food   From   However   If   Implements   Interface   It   March   Names   Obj   Pre   Provide   So   Taken   Writing   adapt   adapter   adapters   advise   an   and   any   attributes   be   behaviour   child   class   cmd   com   convert   create   declared   def   defined   desired   does   eby   edible   enabled   example   find   from   function   have   hurray   id   if   in   init   input   instance   instances   is   it   list   lookup   mail   not   number   object   objects   of   on   or   passed   peak   pipermail   place   print   protocol   provide   provides   return   returns   sarna   self   should   string   takes   that   the   this   thread   to   user   will   wrapper   you  

Clear message


1 Writing Adaptors

Taken from the mail list thread http://www.eby-sarna.com/pipermail/peak/2004-March/001356.html:

Adapting takes an input object, and returns the object if it provides the desired protocol. If the input object does not provide the protocol, a lookup takes place to find an adapter function that will convert the object or create a wrapper to adapt it.

From a user example:

class IEdible(Interface): 
     """Implements an edible behaviour on objects""" 
 
     def __init__(): 
         """a number of attributes that should be enabled in child""" 
 
 
     def PreObj(self, cmd=''): 
         """returns a cmd'string'""" 
 
 
class Food: 
     advise(instancesProvide = [IEdible]) 
 
     def __init__(self, pNames=''): 
         self.id = 12 
 
     def PreObj(self, cmd=''): 
         print 'hurray' 
 
adapt(IEdible, Food) 

Food is a class. It does not provide IEdible, and you have not defined any adapters from it to IEdible.

However, you have declared that instances of Food provide IEdible. So this:

adapt(IEdible,Food())

will return you the Food instance you passed in.


PythonPowered
EditText of this page (last modified 2005-07-29 17:25:06)
FindPage by browsing, title search , text search or an index
Or try one of these actions: AttachFile, DeletePage, LikePages, LocalSiteMap, SpellCheck