2.2.2.2 Basic Binding Classes/Functions

The following functions and classes can be used as-is to create attribute bindings, or you can subclass the classes to create custom binding types of your own:

Make(recipe, **keywords)
The most basic of all binding types, the binding.Once class requires only a callable object such as a function or lambda. If you don't supply an attrName, the "__name__" attribute of the func parameter is used, if available. Similarly, if you don't supply a doc, the "__doc__" attribute of the func parameter is used, if available.

As we've already seen, the binding.Make function just needs a class or type object as its obtype parameter, and it creates a new instance of that type.

binding.Make will also accept a string for its recipe parameter, in which case it will interpret the string as an import specification, using the peak.util.imports.importString function to load it. We'll talk more about import specifications in the chapter on the peak.config package.

Require(description, **keywords)
The binding.Require class is the odd one out in this group. It doesn't compute a value at all! Instead, it raises an error when the attribute is accessed. This is so that you can easily define an attribute that you expect a subclass or instance to provide, and thus get a clearer error message if the expected attribute is never defined.

XXX Need Obtain and Delegate here as well.