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

Class dbobject

source code

object --+
         |
        dbobject
Known Subclasses:
zope_dbobject

Base class for all database aware classes.

It contains a number of helper methods which are called like this: __help__(). You may safely add db-aware properties, regular properties and methods.

Nested Classes [hide private]
  __result__
This attribute must be a class which inherits from result.
  __metaclass__

Instance Methods [hide private]
  __init__(self, **kw)
Construct a dbobj from key word arguments.
  __insert__(self, ds)
This method is called by datasource.insert() after the insert query has been performed.
  __ds__(self)
Return this dbobject's datasource (the one it is stored in).
  __is_stored__(self)
  __repr__(self)
Return a human readable (more or less) representation of this dbobject.
  __eq__(self, other)
Two dbobjects are considered equal, if they have the same dbclass and the same primary key.
  __ne__(self, other)
Same as __eq__, just the other way 'round ;-)
  __widget_specs__(self, module_name)
Return a list of all widget_specs for the module named module_name.
  __delete__(self)
  __update_from_dict__(self, kw)

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__


Class Methods [hide private]
  __from_result__(cls, ds, info)
This constructor is called by datasource.datasource_base when an object is created using a row retreived from the RDBMS.
  __dbproperties__(cls)
Return the datatype objects among this dbobjects attributes as a dict like { name: property, ...
  __dbproperty__(cls, name=None)
Return a dbproperty by its name.
  __has_dbproperty__(cls, name)
Return whether this dbclass has a property named `name`.
  __select_columns__(cls)
A list of columns to select from the relation to construct one of these.

Class Variables [hide private]
  __primary_key__ = 'id'
The primary key must be either
  __relation__
Name of the relation this dbclass' values are stored in.
  __schema__
String containing the name of the schema this dbclass' relatin resides in.

Properties [hide private]
  __model__
Property class the will return the module object of the module the owning class was loaded from.

Inherited from object: __class__


Method Details [hide private]

__init__(self, **kw)
(Constructor)

source code 
Construct a dbobj from key word arguments. Example:
  me = person(firstname='Diedrich', lastname='Vorberg')
firstname and lastname are dbproperties. The reserved parameter __ds allows you to pass a datasource to objects that are not inserted yet and might need a ds to construct views and the like.
Overrides: object.__init__

__from_result__(cls, ds, info)
Class Method

source code 
This constructor is called by datasource.datasource_base when an object is created using a row retreived from the RDBMS.
Parameters:
  • ds - datasource we are created by (see select() method)
  • info - dictionary as { 'column_name': <data> }

__insert__(self, ds)

source code 
This method is called by datasource.insert() after the insert query has been performed. It sets the dbobj's _ds attribute.
Parameters:
  • ds - datasource that just inserted us

__ds__(self)

source code 
Return this dbobject's datasource (the one it is stored in).

__is_stored__(self)

source code 
Returns:
Wheather this dbobj has been stored in the database already or retrieved from it

__dbproperties__(cls)
Class Method

source code 
Return the datatype objects among this dbobjects attributes as a dict like { name: property, ... }

__dbproperty__(cls, name=None)
Class Method

source code 
Return a dbproperty by its name. Raise exceptions if
  • there is no property by that name
  • it's not a dbproperty
name defaults to the dbclass' primary key.

__has_dbproperty__(cls, name)
Class Method

source code 
Return whether this dbclass has a property named `name`.

__select_columns__(cls)
Class Method

source code 
A list of columns to select from the relation to construct one of these.

__repr__(self)
(Representation operator)

source code 
Return a human readable (more or less) representation of this dbobject.
Overrides: object.__repr__

__eq__(self, other)
(Equality operator)

source code 
Two dbobjects are considered equal, if they have the same dbclass and the same primary key. This method does not check any attributes!

__ne__(self, other)

source code 
Same as __eq__, just the other way 'round ;-)

__widget_specs__(self, module_name)

source code 
Return a list of all widget_specs for the module named module_name.

__delete__(self)

source code 
None

__update_from_dict__(self, kw)

source code 
None

Class Variable Details [hide private]

__primary_key__

The primary key must be either
  • a keys.primary_key instance
  • a tuple of strings indicating attribute (not column!) names of this class that form a multi column primary key
  • a simple string indicating the attribute that manages the primary key column of this dbclass
  • None if the class does not have a primary key (which makes it impossible to update rows by updating an instance's attributes through orm)
Value:
'id'                                                                   
      

__relation__

Name of the relation this dbclass' values are stored in. Defaults to the class' name. May be set to a string or an sql.relation instance.

__schema__

String containing the name of the schema this dbclass' relatin resides in.

Property Details [hide private]

__model__

Property class the will return the module object of the module the owning class was loaded from.
Get Method:
None                                                                  
Set Method:
None                                                                  
Delete Method:
None