Package pydo :: Module base :: Class PyDO
[show private | hide private]
[frames | no frames]

Class PyDO

object --+    
         |    
      dict --+
             |
            PyDO


Base class for PyDO data classes.
Method Summary
  __setitem__(self, k, v)
  clear(self)
not implemented for PyDO classes
  commit(cls)
Commit changes to database (Class method)
  copy(self)
returns a copy of self
  delete(self)
remove the row that represents me in the database
  deleteSome(cls, *args, **fieldData)
delete possibly many records at once, and return the number deleted (Class method)
  dict(self)
returns a copy of self as a plain dict
  getColumns(cls, qualifier)
Returns a list of all columns in this table, in no particular order. (Class method)
  getCount(cls, *args, **fieldData)
Retrieve the number of object of this particular class, optionally limited by query arguments. (Class method)
  getDBI(cls)
return the database interface (Class method)
  getFields(cls)
returns the effective fields of the class (Class method)
  getSequences(cls)
returns the effective sequences for the class (Class method)
  getSome(cls, *args, **fieldData)
Retrieve some objects of this particular class. (Class method)
  getTable(cls, withSchema)
returns the name of the table, qualified with the schema, if any, if withSchema is true. (Class method)
  getUnique(cls, **fieldData)
Retrieve one particular instance of this class. (Class method)
  getUniquenessConstraints(cls)
returns the effective uniqueness constraints of the class (Class method)
  joinTable(self, thisAttrNames, pivotTable, thisSideColumns, thatSideColumns, thatObject, thatAttrNames, *whereArgs, **extra)
Handles many to many relations.
  new(cls, **fieldData)
create and return a new data class instance using the values in fieldData. (Class method)
  newfetch(cls, **fieldData)
like new(), but always refetches. (Class method)
  newnofetch(cls, **fieldData)
like new(), but never refetches. (Class method)
  onUpdate(self, adict)
a hook for subclasses to modify/validate updates; by default returns the original data unchanged.
  pop(self)
not implemented for PyDO classes
  popitem(self)
not implemented for PyDO classes
  project(cls, *fields, **kwargs)
(Class method)
  refresh(self)
refetch myself from the database
  rollback(cls)
Rollback current transaction (Class method)
  setdefault(self, key, val)
not implemented for PyDO classes
  update(self, adict)
Part of dictionary interface for field access
  updateSome(cls, adict, *args, **fieldData)
update possibly many records at once, and return the number updated (Class method)
  _baseSelect(cls, qualified)
returns the beginning of a select statement for this object's table. (Class method)
  _create_field(*args, **kwargs)
controls how fields are created when declared in the field list with a simple string, list, tuple, or dictionary rather than a field instance. (Static method)
  _getTableDescription(cls)
Supplies the table fields (as a dict of fieldnames to Field objects) and a list of multi-column unique constraints to the metaclass, which will call it when guessing columns. (Class method)
  _joinTableSQL(self, conn, thisAttrNames, pivotTable, thisSideColumns, thatSideColumns, thatObject, thatAttrNames, extraTables, wheresql, converter, order, limit, offset)
SQL generating function for joinTable
  _matchUnique(cls, kw)
return a tuple of column names that will uniquely identify a row given the choices from kw (Class method)
  _new(cls, fieldData, refetch)
(Class method)
  _processWhere(conn, args, fieldData, converter)
(Static method)
  _sequence_for(cls, field)
(Class method)
  _uniqueWhere(cls, conn, kw, converter)
given a connection and kw, using _matchUnique, generate a where clause to select a unique row. (Class method)
  _update_raw(self, adict)
update self in database with the values in adict
  _validateFields(cls, adict)
a simple field validator that verifies that the keys in the dictionary passed are declared fields in the class. (Class method)
    Inherited from dict
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __cmp__(x, y)
x.__cmp__(y) <==> cmp(x,y)
  __contains__(D, k)
D.__contains__(k) -> True if D has a key k, else False
  __delitem__(x, y)
x.__delitem__(y) <==> del x[y]
  __eq__(x, y)
x.__eq__(y) <==> x==y
  __ge__(x, y)
x.__ge__(y) <==> x>=y
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __getitem__(x, y)
x.__getitem__(y) <==> x[y]
  __gt__(x, y)
x.__gt__(y) <==> x>y
  __hash__(x)
x.__hash__() <==> hash(x)
  __iter__(x)
x.__iter__() <==> iter(x)
  __le__(x, y)
x.__le__(y) <==> x<=y
  __len__(x)
x.__len__() <==> len(x)
  __lt__(x, y)
x.__lt__(y) <==> x<y
  __ne__(x, y)
x.__ne__(y) <==> x!=y
  __repr__(x)
x.__repr__() <==> repr(x)
  get(D, k, d)
D.get(k[,d]) -> D[k] if k in D, else d.
  has_key(D, k)
D.has_key(k) -> True if D has a key k, else False
  items(D)
D.items() -> list of D's (key, value) pairs, as 2-tuples
  iteritems(D)
D.iteritems() -> an iterator over the (key, value) items of D
  iterkeys(D)
D.iterkeys() -> an iterator over the keys of D
  itervalues(D)
D.itervalues() -> an iterator over the values of D
  keys(D)
D.keys() -> list of D's keys
  values(D)
D.values() -> list of D's values
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  fromkeys(dict, S, v)
v defaults to None.

Class Variable Summary
NoneType connectionAlias = None                                                                  
bool guess_columns = False
bool guess_tablename = True
NoneType guesscache = None                                                                  
bool mutable = True
bool refetch = False
NoneType schema = None                                                                  
NoneType sequence_mapper = None                                                                  
str table = 'pydo'
bool use_attributes = True
type __metaclass__ = pydo.base._metapydo
dict _fields = {}
bool _ignore_update_rowcount = False
bool _is_projection = False
dict _projections = {}
dict _sequenced = {}
frozenset _unique = frozenset([])

Instance Method Details

clear(self)

not implemented for PyDO classes
Overrides:
__builtin__.dict.clear

copy(self)

returns a copy of self
Overrides:
__builtin__.dict.copy

delete(self)

remove the row that represents me in the database

dict(self)

returns a copy of self as a plain dict

joinTable(self, thisAttrNames, pivotTable, thisSideColumns, thatSideColumns, thatObject, thatAttrNames, *whereArgs, **extra)

Handles many to many relations. In short, do:

SELECT thatObject.getColumns(1) FROM thatObject.table, pivotTable WHERE pivotTable.thisSideColumn = self.myAttrName AND pivotTable.thatSideColumn = thatObject.table.thatAttrName

and return a list of thatObjects representing the resulting rows. The parameters which accept column names (thisAttrNames, thisSideColumns, thatSideColumns, thatAttrNames) can be strings (silently turned to tuples of length 1) or tuples of strings. For each pair P of the two pairs (thisSideColumns, thisAttrNames) and (thatSideColumns, thatAttrNames) len(P[0]) must equal len(P[1]).

In addition, you can add extra tables and arbitrary sql to the where clause, as you can with getSome(), including order, limit and offset, using the "extraTables", "order", "limit" and "offset" keyword arguments, using SQLOperators or (sql-string, bind values) as positional arguments, and by specifying columns by keyword argument.

onUpdate(self, adict)

a hook for subclasses to modify/validate updates; by default returns the original data unchanged.

pop(self)

not implemented for PyDO classes
Overrides:
__builtin__.dict.pop

popitem(self)

not implemented for PyDO classes
Overrides:
__builtin__.dict.popitem

refresh(self)

refetch myself from the database

setdefault(self, key, val)

not implemented for PyDO classes
Overrides:
__builtin__.dict.setdefault

update(self, adict)

Part of dictionary interface for field access
Overrides:
__builtin__.dict.update

_joinTableSQL(self, conn, thisAttrNames, pivotTable, thisSideColumns, thatSideColumns, thatObject, thatAttrNames, extraTables, wheresql, converter, order, limit, offset)

SQL generating function for joinTable

_update_raw(self, adict)

update self in database with the values in adict

Static Method Details

_create_field(*args, **kwargs)

controls how fields are created when declared in the field list with a simple string, list, tuple, or dictionary rather than a field instance. By default, passes field declaration to the Field constructor.

Class Method Details

commit(cls)

Commit changes to database

deleteSome(cls, *args, **fieldData)

delete possibly many records at once, and return the number deleted

getColumns(cls, qualifier=None)

Returns a list of all columns in this table, in no particular order.

If qualifier is true, returns fully qualified column names (i.e., table.column). If you pass in a string to qualifier, it will be used as a table alias; otherwise the table name will be used.

getCount(cls, *args, **fieldData)

Retrieve the number of object of this particular class, optionally limited by query arguments.

getDBI(cls)

return the database interface

getFields(cls)

returns the effective fields of the class

getSequences(cls)

returns the effective sequences for the class

getSome(cls, *args, **fieldData)

Retrieve some objects of this particular class.

[todo: examples of use of operators, column-name keyword args, order, limit, and offset.]

If you use SQL directly and pass variables, it is up to you to use the same paramstyle as the underlying driver.

getTable(cls, withSchema=True)

returns the name of the table, qualified with the schema, if any, if withSchema is true.

getUnique(cls, **fieldData)

Retrieve one particular instance of this class.

Given the attribute/value pairs in fieldData, retrieve a unique row and return a data class instance representing said row or None if no row was retrieved.

getUniquenessConstraints(cls)

returns the effective uniqueness constraints of the class

new(cls, **fieldData)

create and return a new data class instance using the values in fieldData. This will also effect an INSERT into the database. If the keyword argument refetch is passed and is true, or, if it is not and cls.refetch is true, effectively do a getUnique on cls.

newfetch(cls, **fieldData)

like new(), but always refetches.

newnofetch(cls, **fieldData)

like new(), but never refetches.

rollback(cls)

Rollback current transaction

updateSome(cls, adict, *args, **fieldData)

update possibly many records at once, and return the number updated

_baseSelect(cls, qualified=False)

returns the beginning of a select statement for this object's table.

_getTableDescription(cls)

Supplies the table fields (as a dict of fieldnames to Field objects) and a list of multi-column unique constraints to the metaclass, which will call it when guessing columns. If cls.guesscache is false, this delegates directly to the DBI driver's describeTable() method, and performs no caching; otherwise, cls.guesscache is presumed to be something compatible a pydo.GuessCache, and it will be consulted and populated.

_matchUnique(cls, kw)

return a tuple of column names that will uniquely identify a row given the choices from kw

_uniqueWhere(cls, conn, kw, converter=None)

given a connection and kw, using _matchUnique, generate a where clause to select a unique row.

_validateFields(cls, adict)

a simple field validator that verifies that the keys in the dictionary passed are declared fields in the class.

Class Variable Details

connectionAlias

Type:
NoneType
Value:
None                                                                  

guess_columns

Type:
bool
Value:
False                                                                  

guess_tablename

Type:
bool
Value:
True                                                                   

guesscache

Type:
NoneType
Value:
None                                                                  

mutable

Type:
bool
Value:
True                                                                   

refetch

Type:
bool
Value:
False                                                                  

schema

Type:
NoneType
Value:
None                                                                  

sequence_mapper

Type:
NoneType
Value:
None                                                                  

table

Type:
str
Value:
'pydo'                                                                 

use_attributes

Type:
bool
Value:
True                                                                   

_fields

Type:
dict
Value:
{}                                                                     

_ignore_update_rowcount

Type:
bool
Value:
False                                                                  

_is_projection

Type:
bool
Value:
False                                                                  

_projections

Type:
dict
Value:
{}                                                                     

_sequenced

Type:
dict
Value:
{}                                                                     

_unique

Type:
frozenset
Value:
frozenset([])                                                          

Generated by Epydoc 2.0 on Wed Mar 8 10:18:58 2006 http://epydoc.sf.net