# sqlobject.boundattributes module

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.

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.

class sqlobject.boundattributes.BoundAttribute(*args, **kw)

  Bases: `Declarative`

  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`.

  clone_for_subclass = True
  declarative_count = 1
  classmethod make_object(added_class, attr_name, *args, **attrs)
  classmethod set_object(added_class, attr_name, obj)

class sqlobject.boundattributes.BoundFactory(*args, **kw)

  Bases: `BoundAttribute`

  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.

  declarative_count = 2
  factory_class = None
  make_object(added_class, attr_name, *args, **kw)