# `boundattributes`

#### Bound attributes are attributes that are bound to a specific class and a specific name. In SQLObject a typical example is a column object, which knows its name and class.

The boundattributes module is accessible via the `sqlobject` module.

A bound attribute should define a method `__addtoclass__(added_class, name)` (attributes without this method will simply be treated as normal). The return value is ignored; if the attribute wishes to change the value in the class, it must call `setattr(added_class, name, new_value)`.

BoundAttribute is a class that facilitates lazy attribute creation.

`bind_attributes(cls, new_attrs)` is a function that looks for attributes with this special method. `new_attrs` is a dictionary, as typically passed into `__classinit__` with declarative (calling `bind_attributes` in `__classinit__` would be typical).

Note if you do this that attributes defined in a superclass will not be rebound in subclasses. If you want to rebind attributes in subclasses, use `bind_attributes_local`, which adds a `__bound_attributes__` variable to your class to track these active attributes.

## Attributes

#### a `__package__`

    'sqlobject'

## Classes

#### C `BoundAttribute(...)` ...

This is a declarative class that passes all the values given to it to another object. So you can pass it arguments (via __init__/__call__) or give it the equivalent of keyword arguments through subclassing. Then a bound object will be added in its place.

To hook this other object in, override `make_object(added_class, name, **attrs)` and maybe `set_object(added_class, name, **attrs)` (the default implementation of `set_object` just resets the attribute to whatever `make_object` returned).

Also see `BoundFactory`.

This class contains 16 members.

#### C `BoundFactory(...)` ...

This will bind the attribute to whatever is given by `factory_class`. This factory should be a callable with the signature `factory_class(added_class, attr_name, *args, **kw)`.

The factory will be reinvoked (and the attribute rebound) for every subclassing.

This class contains 17 members.

See the source for more information.