Table of Contents

Module: adapters ./src/protocols/adapters.py

Basic Adapters and Adapter Operations

Imported modules   
from types import FunctionType, ClassType, MethodType
Functions   
DOES_NOT_SUPPORT
NO_ADAPTER_NEEDED
bindAdapter
composeAdapters
minimumAdapter
updateWithSimplestAdapter
  DOES_NOT_SUPPORT 
DOES_NOT_SUPPORT ( obj,  protocol=None )

Prevent obj from supporting protocol

  NO_ADAPTER_NEEDED 
NO_ADAPTER_NEEDED ( obj,  protocol=None )

Assume obj implements protocol directly

  bindAdapter 
bindAdapter ( adapter,  proto )

Backward compatibility: wrap adapter to support old 2-arg signature

  composeAdapters 
composeAdapters (
        baseAdapter,
        baseProtocol,
        extendingAdapter,
        )

Return the composition of 'baseAdapter'+extendingAdapter

  minimumAdapter 
minimumAdapter (
        a1,
        a2,
        d1=0,
        d2=0,
        )

Shortest route to implementation, a1 @ depth d1, or a2 @ d2?

Assuming both a1 and a2 are interchangeable adapters (i.e. have the same source and destination protocols), return the one which is preferable; that is, the one with the shortest implication depth, or, if the depths are equal, then the adapter that is composed of the fewest chained adapters. If both are the same, then prefer NO_ADAPTER_NEEDED, followed by anything but DOES_NOT_SUPPORT, with DOES_NOT_SUPPORT being least preferable. If there is no unambiguous choice, and not a1 is a2, TypeError is raised.

Exceptions   
TypeError( "Ambiguous adapter choice", a1, a2, d1, d2 )
  updateWithSimplestAdapter 
updateWithSimplestAdapter (
        mapping,
        key,
        adapter,
        depth,
        )

Replace 'mapping[key]' w/adapter @ depth, return true if changed

Classes   

AdaptationFailure

A suitable implementation/adapter could not be found

Adapter

Convenient base class for adapters

StickyAdapter

Adapter that attaches itself to its subject for repeated use


Table of Contents

This document was automatically generated on Mon Dec 16 01:11:12 2024 by HappyDoc version 2.1