Module bazaar.assoc
Association classes.
There are several types of associations:
-
one-to-one
-
one-to-many
-
many-to-many
All of them can be:
-
uni-directional
-
bi-directional
Defining associations between application classes is described in
documentation of bazaar.conf
module.
Referenced objects are accessed in object-oriented manner:
# create objects
ord = Order()
oi = OrderItem()
art = Article()
# assign reference
oi.article = art
# append object reference to list of objects of one-to-many association
ord.items.append(oi)
for oi in ord.items:
print oi.article
Getting object reference (oi.article
) or iterator of
referenced objects (ord.items
) is performed with descriptors
(see below). Iterator of objects is implemented with bazaar.assoc.ObjectIterator
class. The
class makes possible operating on objects, i.e. appending objects into
relationship.
One side of specific relationship is realized with one class
descriptor:
+------------------------------------------------------------------------+
| Association | Uni-directional | Bi-directional |
+------------------------------------------------------------------------+
| | A | B | A | B |
+------------------------------------------------------------------------+
| one-to-one | OneToOne | OneToOne | BiDirOneToOne | BiDirOneToOne |
| one-to-many | OneToOne | --- | OneToMany | BiDirOneToOne |
| many-to-many | List | List | BiDirManyToMany | BiDirManyToMany |
+------------------------------------------------------------------------+
where:
A < 1 ------ 1 > B one-to-one
A < 1 ------ * > B one-to-many
A < * ------ * > B many-to-many
Classes |
AssociationReferenceProxy |
Association reference proxy class for application objects. |
BiDirList |
Basic bi-directional one-to-many and many-to-many association
descriptor. |
BiDirManyToMany |
Bi-directional many-to-many association descriptor. |
BiDirOneToOne |
Bi-directional one-to-one association descriptor. |
List |
Basic descriptor for one-to-many and many-to-many associations. |
ObjectIterator |
Iterator of referenced objects of one-to-many and many-to-many
associations. |
OneToMany |
One-to-many association descriptor. |
OneToOne |
Class for uni-directional one-to-one association descriptors. |
Function Summary |
|
juggle (obj,
value,
app,
rem)
Dictionaries app and rem contain sets of
referenced objects indexed by application objects obj . |
Variable Summary |
Log |
log = <bazaar.Log object at 0x300b0d10>
|
juggle(obj,
value,
app,
rem)
Dictionaries app and rem contain sets of
referenced objects indexed by application objects obj .
Function appends referenced object value to set
app[obj] and removes it from rem[obj] . If set
rem[obj] contains no values, then it is deleted.
-
|
log
-
- Type:
-
Log
- Value:
<bazaar.Log object at 0x300b0d10>
|
|