Package bazaar :: Module assoc :: Class ObjectIterator
[show private | hide private]
[frames | no frames]

Type ObjectIterator

object --+
         |
        ObjectIterator


Iterator of referenced objects of one-to-many and many-to-many associations.

The iterator is used to append, remove and update referenced objects, which are associated with application object.

For example, to print articles of order's items:
   items = order.items    # get ObjectIterator object
   for oi in items:
       print oi.article
Several operators are supported

See Also: AssociationReferenceProxy

Method Summary
  __init__(self, obj, association)
Create iterator of referenced objects.
  __contains__(self, value)
Check if object is referenced in the relationship.
  __delitem__(self, value)
Remove referenced object from association.
  __iter__(self)
Iterator interface method.
  __len__(self)
Return amount of referenced objects.
  append(self, value)
Associate referenced object with application object.
  remove(self, value)
Remove referenced object from association.
  update(self)
Update association data in database.
    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)

Instance Variable Summary
  association: Association object.
  obj: Application object.

Method Details

__init__(self, obj, association)
(Constructor)

Create iterator of referenced objects.
Parameters:
obj - Application object.
association - One-to-many or many-to-many association object.
Overrides:
__builtin__.object.__init__

__contains__(self, value)
(In operator)

Check if object is referenced in the relationship.
Parameters:
value - Object to check.
Returns:
True if object is referenced.

__delitem__(self, value)
(Index deletion operator)

Remove referenced object from association.

Method works for bi-directional associations, too:
   order.items.remove(oi)        # oi.order == None
or:
   del order.items[oi]           # oi.order == None
Referenced object cannot be None.
Parameters:
value - Referenced object.

__iter__(self)

Iterator interface method.
Returns:
Iterator of all referenced objects got from association object.

__len__(self)
(Length operator)

Return amount of referenced objects.

append(self, value)

Associate referenced object with application object.

Method works for bi-directional associations, too:
   oi = OrderItem()
   order.items.append(oi)        # oi.order == oi
Referenced object cannot be None.
Parameters:
value - Referenced object.

remove(self, value)

Remove referenced object from association.

Method works for bi-directional associations, too:
   order.items.remove(oi)        # oi.order == None
or:
   del order.items[oi]           # oi.order == None
Referenced object cannot be None.
Parameters:
value - Referenced object.

update(self)

Update association data in database.

Instance Variable Details

association

Association object.

obj

Application object.

Generated by Epydoc 2.1 on Tue May 10 18:27:30 2005 http://epydoc.sf.net