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

Class relationship

source code

    object --+        
             |        
      property --+    
                 |    
datatypes.datatype --+
                     |
                    relationship
Known Subclasses:
_2many, many2one, one2one

Base class for all relationships.

For documentation of the other parameters refer to the constructor of datatype.datatype.

Instance Methods [hide private]
  __init__(self, child_class, child_key=None, foreign_key=None, title=None, has_default=None)
  __set_from_result__(self, ds, dbobj, value)
  isset(self, dbobj)
  __convert__(self, value)
Relationships do not need a convert method or can't use it anyway.
  sql_literal(self, dbobj)
This relationship cannot be represented as an SQL literal.
  __select_this_column__(self)
  __select_after_insert__(self, dbobj)

Inherited from datatypes.datatype: __delete__, __get__, __init_dbclass__, __set__, __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__(self, child_class, child_key=None, foreign_key=None, title=None, has_default=None)
(Constructor)

source code 
Parameters:
  • child_class - The dbclass, this property's owner has a relationship to
  • child_key - A string or a tuple of strings indicating those properties of the child_class that are used in the foreign key. This defaults to the child's primary key. The child_key must match the foreign_key in the number of its members and the attribute's datatypes.
  • foreign_key - The foreign key. Simmlar to a dbclass' primary key this may be a simple string, indication the attribute that manages the foreign key column or a tuple of strings indicating columns that form the foreign key together. If the foreign key parameter is None __init_dbclass__() will try to guess the foreign key name as 'child's table'_'primary key column'.
Overrides: datatypes.datatype.__init__

__set_from_result__(self, ds, dbobj, value)

source code 
None
Overrides: datatypes.datatype.__set_from_result__

isset(self, dbobj)

source code 
Returns:
True. Most relationships are always set, even if they return [] or the like.
Overrides: datatypes.datatype.isset

__convert__(self, value)

source code 
Relationships do not need a convert method or can't use it anyway.
Overrides: datatypes.datatype.__convert__

sql_literal(self, dbobj)

source code 
This relationship cannot be represented as an SQL literal.
Returns:
SQL literal as a string.
Overrides: datatypes.datatype.sql_literal

__select_this_column__(self)

source code 
Returns:
False. Most relationships do not need to select anything.
Overrides: datatypes.datatype.__select_this_column__

__select_after_insert__(self, dbobj)

source code 
Returns:
False. Most relationships to not need to select anything, even after the insert.
Overrides: datatypes.datatype.__select_after_insert__