Package Gnumed :: Package pycommon :: Module gmBusinessDBObject :: Class cBusinessDBObject
[frames] | no frames]

Class cBusinessDBObject

source code

object --+
         |
        cBusinessDBObject
Known Subclasses:

Represents business objects in the database.

Rules:
- instances ARE ASSUMED TO EXIST in the database
- PK construction (aPK_obj): DOES verify its existence on instantiation
                             (fetching data fails)
- Row construction (row): allowed by using a dict of pairs
                               field name: field value (PERFORMANCE improvement)
- does NOT verify FK target existence
- does NOT create new entries in the database
- does NOT lazy-fetch fields on access

Class scope SQL commands and variables:

<_cmd_fetch_payload>
        - must return exactly one row
        - where clause argument values are expected
          in self.pk_obj (taken from __init__(aPK_obj))
        - must return xmin of all rows that _cmds_store_payload
          will be updating, so views must support the xmin columns
          of their underlying tables

<_cmds_store_payload>
        - one or multiple "update ... set ... where xmin_* = ..." statements
          which actually update the database from the data in self._payload,
        - the last query must refetch the XMIN values needed to detect
          concurrent updates, their field names had better be the same as
          in _cmd_fetch_payload

<_updatable_fields>
        - a list of fields available for update via object['field']

Instance Methods
 
__del__(self) source code
 
__getitem__(self, attribute) source code
 
__init__(self, aPK_obj=None, row=None)
Init business object.
source code
 
__setitem__(self, attribute, value) source code
 
__str__(self)
str(x)
source code
 
get_fields(self) source code
 
get_patient(self) source code
 
get_updatable_fields(self) source code
 
is_modified(self) source code
 
refetch_payload(self, ignore_changes=False)
Fetch field values from backend.
source code
 
same_payload(self, another_object=None) source code
 
save(self, conn=None) source code
 
save_payload(self, conn=None)
Store updated values (if any) in database.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, aPK_obj=None, row=None)
(Constructor)

source code 

Init business object.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

save_payload(self, conn=None)

source code 
Store updated values (if any) in database.

Optionally accepts a pre-existing connection
- returns a tuple (<True|False>, <data>)
- True: success
- False: an error occurred
        * data is (error, message)
        * for error meanings see gmPG2.run_rw_queries()