Package pydo :: Module base :: Class ForeignKey
[show private | hide private]
[frames | no frames]

Class ForeignKey

object --+
         |
        ForeignKey


descriptor that enables succinct creation of foreign key attributes.
Both single-column and multi-column foreign key associations are supported.

Example usage:

class A(PyDO):
    fields=(Sequence('id'),
            'b_fkey',
            'c_fkey1',
            'c_fkey2')
    B=ForeignKey('b_fkey', 'id', B)
    C=ForeignKey(('c_fkey1', 'c_fkey2'), ('key1', 'key2'), C)

a=A.getUnique(id=1)
a.B # returns B.getUnique(id=a.b_fkey)
a.C # returns C.getUnique(key1=a.c_fkey1, key2=a.c_fkey2)
a.C=my_C_instance # updates a with new values for c_fkey1 and c_fkey2 
a.B=None # equivalent to a.b_fkey=None

Method Summary
  __init__(self, this_side, that_side, kls)
  __get__(self, obj, type_)
  __set__(self, obj, value)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __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)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T

Property Summary
  kls

Method Details

__init__(self, this_side, that_side, kls)
(Constructor)

Parameters:
this_side - name(s) of the column(s) in this PyDO class which references the key of another table
           (type=string or sequence)
that_side - name(s) of the column(s) in the other PyDO class being referenced
           (type=string or sequence)
kls - the other PyDO class
           (type=PyDO)
Overrides:
__builtin__.object.__init__

Property Details

kls

Get Method:
fget(...)

Generated by Epydoc 2.0 on Wed Mar 8 10:18:59 2006 http://epydoc.sf.net