Package dejavu :: Module units :: Class Unit
[show private | hide private]
[frames | no frames]

Type Unit

object --+
         |
        Unit


Unit(**kwarg properties). A generic, persistent object.

Units are the building-block of Dejavu. They are purposefully lightweight,
relying on Sandboxes to cache them, which in turn rely on Storage Managers
to load and save them.

They maintain their own "schema" via UnitProperty objects, so that the
Storage Managers don't need to know every detail about every Unit.
Storage Managers for simple databases, for example, will simply create
a single flat table for each unit type. If you write a custom Storage
Manager, you can do as you like; the only place you might run into a
problem is if you write a custom Storage Manager for custom Unit types,
because the knowledge between the two is indeterminate. For example,
if we provide a standard StorageManagerForLotusNotes, and you create
custom Units which interface with it, you should probably subclass and
extend our StorageManagerForLotusNotes with some custom storage logic.

sandbox: The sandbox in which the Unit "lives". Also serves as a flag
    indicating whether this Unit has finished the initial creation
    process.
    
    Sandboxes receive Units during recall() and memorize();
    these processes should set the sandbox attribute.

dirty: indicates whether elements in the _properties dictionary
    have been modified. This flag is used by Sandboxes to optimize
    forget(): they do not ask Storage Managers to save data for Units
    which have not been modified. Because SM's may cache Units, no code
    should set this flag other than UnitProperty.__set__ and SM's.

Method Summary
  __init__(self, **kwargs)
  __copy__(self)
  __getstate__(self)
  __setstate__(self, state)
  add(self, *units)
Auto-create a relation between self and unit(s).
  associate(nearClass, nearKey, farClass, farKey, nearDescriptor, farDescriptor)
Set UnitAssociations between nearClass.key and farClass.farKey. (Class method)
  associations(cls)
Return a list of UnitAssociation names. (Class method)
  cleanse(self)
  dirty(self)
  forget(self)
Destroy this Unit.
  identity(self)
  indices(cls)
Return a tuple of names of indexed UnitProperties. (Class method)
  many_to_one(nearClass, nearKey, farClass, farKey)
(Class method)
  one_to_many(nearClass, nearKey, farClass, farKey)
(Class method)
  one_to_one(nearClass, nearKey, farClass, farKey)
(Class method)
  remove_property(cls, key)
(Class method)
  repress(self)
Remove this Unit from memory (do not destroy).
  set_properties(cls, types, descriptor)
Set Unit Properties for cls. (Class method)
  set_property(cls, key, type, index, descriptor)
Set a Unit Property for cls. (Class method)
  update(self, **values)
Modify this Unit's property values (via keyword arguments).
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
type __metaclass__ = dejavu.units.MetaUnit
UnitProperty ID = dejavu.units.UnitProperty(type=int, index=True, hin...
tuple identifiers = ('ID',)
list properties = ['ID']
UnitSequencerInteger sequencer = <dejavu.units.UnitSequencerInteger object at...

Instance Method Details

add(self, *units)

Auto-create a relation between self and unit(s).

forget(self)

Destroy this Unit.

repress(self)

Remove this Unit from memory (do not destroy).

update(self, **values)

Modify this Unit's property values (via keyword arguments).

The keyword arguments you supply will be checked against this Unit's known properties; only known properties will be updated. This keeps applications which accept arbitrary parameters safer.

Class Method Details

associate(nearClass, nearKey, farClass, farKey, nearDescriptor, farDescriptor)

Set UnitAssociations between nearClass.key and farClass.farKey.

associations(cls)

Return a list of UnitAssociation names.

indices(cls)

Return a tuple of names of indexed UnitProperties.

set_properties(cls, types={}, descriptor=<class 'dejavu.units.UnitProperty'>)

Set Unit Properties for cls.

set_property(cls, key, type=<type 'unicode'>, index=False, descriptor=<class 'dejavu.units.UnitProperty'>)

Set a Unit Property for cls.

Class Variable Details

ID

Type:
UnitProperty
Value:
dejavu.units.UnitProperty(type=int, index=True, hints={}, key='ID', de\
fault=None)                                                            

identifiers

Type:
tuple
Value:
('ID',)                                                                

properties

Type:
list
Value:
['ID']                                                                 

sequencer

Type:
UnitSequencerInteger
Value:
<dejavu.units.UnitSequencerInteger object at 0x88d1e8c>                

Generated by Epydoc 2.1 on Thu Jul 19 15:32:16 2007 http://epydoc.sf.net