Package orm2 :: Module relationships :: Class one2many
[hide private]
[frames] | no frames]

Class one2many

source code

    object --+                
             |                
      property --+            
                 |            
datatypes.datatype --+        
                     |        
          relationship --+    
                         |    
                    _2many --+
                             |
                            one2many

A one2many relationship is probably the most common relationship between two tables in a RDBMS. For each row in table A table B contains zero or more rows. This is implemented by defining a column in table B that contains values that uniquly specify the row in table A they belong to. This is called a 'foreign key', i.e. a key that belongs to a foreign table.

Nested Classes [hide private]
  result

Instance Methods [hide private]
  __init_dbclass__(self, dbclass, attribute_name)
This methods gets called by dbobject's metaclass.
  __set__(self, dbobj, value)
Setting a one2many relationship needs three steps:

Inherited from _2many: __get__

Inherited from relationship: __convert__, __init__, __select_after_insert__, __select_this_column__, __set_from_result__, isset, sql_literal

Inherited from datatypes.datatype: __delete__, __setattr__, add_widget, check_dbobj, data_attribute_name, widget_specs

Inherited from property: __getattribute__, __new__

Inherited from object: __delattr__, __hash__, __reduce__, __reduce_ex__, __repr__, __str__


Class Variables [hide private]

Inherited from datatypes.datatype: python_class, sql_literal_class

Inherited from property: fdel, fget, fset


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init_dbclass__(self, dbclass, attribute_name)

source code 
This methods gets called by dbobject's metaclass. It supplies the db property with info about the class it belongs to and its attribute name.
Overrides: _2many.__init_dbclass__

__set__(self, dbobj, value)

source code 
Setting a one2many relationship needs three steps:
  1. value must be a list of new (not-yet inserted) child objects
  2. delete all child objects from the db
  3. insert all child objects on the list with the foreign key pointing to dbobj
Overrides: _2many.__set__