Package eoxserver :: Package core :: Module records :: Class RecordWrapperInterface
[hide private]
[frames] | no frames]

Class RecordWrapperInterface

source code


This class defines an interface for simple lazy record wrappers which are used throughout EOxServer to couple data and metadata stored in the configuration database with additional application logic. Implementations of this interface shall wrap a model record and couple it with additional attributes and dynamic behaviour. The wrapper shall be lazy, i.e. any changes to the model record or to the attributes will not affect the database until the programmer explicitly calls :meth:`save`, :meth:`getRecord`. .. method:: getType This method shall return the type of record the wrapper represents. This method is needed especially by factories which return multiple classes of :class:`RecordWrapperInterface` implementations that wrap models inheriting from a common base model. .. method:: setRecord(record) This method shall initialize the record wrapper with an existing model record. It shall raise :exc:`~.InternalError` in case the record is of an incompatible type .. method:: setAttrs(**kwargs) This method shall initialize the record wrapper with implementation dependent attributes. It shall raise :exc:`~.InternalError` in case there are mandatory attributes missing. .. method:: sync(fetch_existing=False) Synchronize with the database, i.e. fetch or create a record with the instance attributes. The method shall respect uniqueness constraints on the underlying model, i.e. return an existing record matching the instance attributes if possible and create a new one only if all constraints are satisfied. In case neither is possible :exc:`~.UniquenessViolation` shall be raised. If the optional ``fetch_existing`` argument is set to ``True``, try to get an existing record with the same attributes from the database even if no uniqueness constraints apply. If there is none, create a new one. .. method:: getRecord(fetch_existing=False) Return the record wrapped by the implementation. If none has been defined yet, fetch or create one with the instance attributes. The method shall respect uniqueness constraints on the underlying model, i.e. return an existing record matching the instance attributes if possible and create a new one only if all constraints are satisfied. In case neither is possible :exc:`~.UniquenessViolation` shall be raised. If the optional ``fetch_existing`` argument is set to ``True``, try to get an existing record with the same attributes from the database even if no uniqueness constraints apply. If there is none, create a new one. .. method:: delete(commit=True) Delete the model record and perform any related logic. This method accepts an optional boolean parameter ``commit`` which defaults to ``True``. If it is set to ``False`` do not actually delete the record, but do perform the additional logic. This is useful for bulk deletion by factories; it should be used with great care as it might leave the system in an inconsistent state if the database record is not removed afterwards.
Nested Classes [hide private]

Inherited from registry.RegisteredInterface: __metaclass__

Instance Methods [hide private]

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from registry.RegisteredInterface: getBindingMethod, getInterfaceId, getRegistryKeys

Inherited from interfaces.Interface: implement

Class Variables [hide private]
  REGISTRY_CONF = {'binding_method': 'factory', 'intf_id': 'core...
  getType = Method(returns= StringArg("@return"))
  setRecord = Method(ObjectArg("record"))
  setAttrs = Method(KwArgs("kwargs"))
  sync = Method(BoolArg("fetch_existing", default= False))
  getRecord = Method(BoolArg("fetch_existing", default= False), ...
  delete = Method(BoolArg("commit", default= True))
  __rconf__ = {'binding_method': 'factory', 'intf_id': 'core.rec...

Inherited from interfaces.Interface: __iconf__

Properties [hide private]

Inherited from object: __class__

Class Variable Details [hide private]

REGISTRY_CONF

Value:
{'binding_method': 'factory',
 'intf_id': 'core.records.RecordWrapperInterface',
 'name': 'Record Wrapper Interface'}

getRecord

Value:
Method(BoolArg("fetch_existing", default= False), returns= ObjectArg("\
@return"))

__rconf__

Value:
{'binding_method': 'factory',
 'intf_id': 'core.records.RecordWrapperInterface',
 'name': 'Record Wrapper Interface'}