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)[source]¶ Bases:
sqlobject.declarative.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 maybeset_object(added_class, name, **attrs)
(the default implementation ofset_object
just resets the attribute to whatevermake_object
returned).Also see
BoundFactory
.-
clone_for_subclass
= True¶
-
declarative_count
= 1¶
-
-
class
sqlobject.boundattributes.
BoundFactory
(*args, **kw)[source]¶ Bases:
sqlobject.boundattributes.BoundAttribute
This will bind the attribute to whatever is given by
factory_class
. This factory should be a callable with the signaturefactory_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¶
-