# sqlobject.declarative module

Declarative objects.

Declarative objects have a simple protocol: you can use classes in lieu of instances and they are equivalent, and any keyword arguments you give to the constructor will override those instance variables. (So if a class is received, we’ll simply instantiate an instance with no arguments).

You can provide a variable __unpackargs__ (a list of strings), and if the constructor is called with non-keyword arguments they will be interpreted as the given keyword arguments.

If __unpackargs__ is (‘*’, name), then all the arguments will be put in a variable by that name.

You can define a __classinit__(cls, new_attrs) method, which will be called when the class is created (including subclasses). Note: you can’t use super() in __classinit__ because the class isn’t bound to a name. As an analog to __classinit__, Declarative adds __instanceinit__ which is called with the same argument (new_attrs). This is like __init__, but after __unpackargs__ and other factors have been taken into account.

If __mutableattributes__ is defined as a sequence of strings, these attributes will not be shared between superclasses and their subclasses. E.g., if you have a class variable that contains a list and you append to that list, changes to subclasses will effect superclasses unless you add the attribute here.

Also defines classinstancemethod, which acts as either a class method or an instance method depending on where it is called.

class `sqlobject.declarative.``classinstancemethod`(func)

  Bases: `object`

  Acts like a class method when called from a class, like an instance method when called by an instance. The method should take two arguments, ‘self’ and ‘cls’; one of these will be None depending on how the method was called.

class `sqlobject.declarative.``DeclarativeMeta`

  Bases: `type`

class `sqlobject.declarative.``Declarative`(*args, **kw)

  Bases: `object`

  `declarative_count` = 0
  `singleton` = <bound class method Declarative.singleton>