|
Methods defined here:
- __getattribute__(self, attrName)
- Return getattr(self, name).
- __init__(self, **kwargs)
- __init__ - Create an object of this type.
Arguments are in form of fieldName=fieldValue
- __repr__(self)
- __repr__ - Get object representation of this instance
@return <str> - A descriptive string of this object
- asDict(self, includePk=True)
- asDict - Return a dict representation of this model
- delete(self, dbConn=None)
- delete - Delete current object.
Should generally NOT be used, instead things should be "archived" to the best of ability.
Will clear the primary key field on this object.
If object is already deleted, this will return None
@param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use,
if None generate a new connection with global settings
@return - Old ID
- getRelated(self, relationKey)
- getRelated - Returns the objects following the relation assigned to #relationKey
@param relationKey <str/???> - The key used in #getModelRelations to describe this relation
@return - If OneToOneRelation, a single object or None, if ManyToOne or OneToMany a list of objs
- insertObject(self, dbConn=None, doCommit=True)
- insertObject - Inserts current object
@param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use,
if None generate a new connection with global settings
@param doCommit <bool> default True - If True, will commit upon insert.
If False, you must call dbConn.commitTransaction yourself when ready.
Primary key is set either way.
If doCommit is False, dbConn must be specified (obviously, so you can commit later)
Will raise exception if object is already saved, or a REQUIRED_FIELDS is not present.
- updateObject(self, updateFieldNames, dbConn=None, doCommit=True)
- updateObject - Performs an UPDATE on a given list of field names, based on value held on current object.
@param updateFieldNames < list<str> > - A list of field names to update.
@param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use,
if None generate a new connection with global settings
@param doCommit <bool> default True - If True, will commit upon insert.
If False, you must call dbConn.commitTransaction yourself when ready.
Primary key is set either way.
If doCommit is False, dbConn must be specified (obviously, so you can commit later)
Will raise exception if current object is not saved.
Class methods defined here:
- all(orderByField=None, orderByDir='', dbConn=None) from builtins.type
- all - Get all objects associated with this model
@param orderByField <None/str> Default None, if provided the list returned
will be ordered by this sql field
@param orderByDir <str> Default empty string, if provided the list will be ordered
in this direction (DESC or ASC)
@param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use,
if None generate a new connection with global settings
@return list<DatabaseModel> - A list of all objects in the database for this model
- createAndSave(dbConn=None, doCommit=True, **kwargs) from builtins.type
- createAndSave - Creates an object of this type and saves it.
Parameters are the fieldName=fieldValue for this model.
At least all entries in REQUIRED_FIELDS must be present!
@param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use,
if None generate a new connection with global settings
@param doCommit <bool> default True - If True, will commit upon insert.
If False, you must call dbConn.commitTransaction yourself when ready.
Primary key is set either way.
If doCommit is False, dbConn must be specified (obviously, so you can commit later)
@return - An object of this model's type
- filter(whereType='AND', dbConn=None, **kwargs) from builtins.type
- filter - Filter and return objects of this type
@param whereType <WHERE_AND/WHERE_OR> - Whether filter criteria should be AND or OR'd together
@param dbConn <DatabaseConnection/None> default None- If present and not None,
will use this as the postgres connection.
Otherwise, will start a new connection based on global settings
Optionals:
@param orderByField - If present, results will be ordered using this field
@param orderByDir - If present, ordered results will follow this direction
All other parameters should be in the form "fieldName=value" for equality comparison,
otherwise fieldName should end with __OPERATION, e.x. fieldName__ne=value for not-equals,
fieldName__like="Start%End" for like, etc.
@return list<objs> - List of objects of this model type
- get(_pk, dbConn=None) from builtins.type
- get - Gets a single object of this model type by primary key (id)
@param _pk <str/int> - Value of primary key"
@param dbConn <None/DatabaseConnection> Default None- A specific DatabaseConnection to use,
if None generate a new connection with global settings
@return object of this type with all fields populated
- getModelRelations() from builtins.type
- getModelRelations - This method should return a list of relations.ForeignRelation objects
for any relations on this object.
This is a method instead of a property so that you can import models within this function
without creating circular references.
This method will be called once per class and the value cached.
@return dict < <str> : relations.ForeignRelations> - Foreign relations on this model
If the key is a string, this model will gain an attribute with that name which will
return the related model when accessed.
For example, { 'person' : OneToManyRelation('id_person', Person, 'id') }
If you access myModelObj.person it will return the Person object related by Person.id = myModel.id_person
The key could also be a model class or whatever, and you can get the related object(s)
by calling myModelObj.getRelated(#key)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- DEFAULT_FIELD_VALUES = {}
- FIELDS = []
- MODEL_RELATIONS = []
- PRIMARY_KEY = 'id'
- REQUIRED_FIELDS = []
- SERIAL_PRIMARY_KEY = True
- TABLE_NAME = None
|