Package Modeling :: Module DatabaseChannel :: Class DatabaseChannel
[show private | hide private]
[frames | no frames]

Class DatabaseChannel


The DatabaseChannel's reponsability is to fetch objects on behalf of a DatabaseContext.

It uses an concrete AdaptorChannel to perform the fetch, it then builds DatabaseObject from the fetched rows, and returns those objects to the requesting DatabaseContext --the DatabaseContext uses 'fetchObject()' to get each object after another.

Note about inheritance: the DatabaseChannel does not care about inheritance. When it gets a request/FetchSpecification for a given entity it fetches rows from the database table 'entity.externalName()' and from this one only, whatever the 'isDeep' flag of the FetchSpecification is. It is the DatabaseContext responsability to correctly drive the DatabaseChannel (see DatabaseContext.objectsWithFetchSpecification())


Method Summary
  __init__(self, aDatabaseContext)
Initializes a new DatabaseChannel and registers it with 'aDatabaseContext'.
  adaptorChannel(self)
Returns the underlying concrete AdaptorChannel.
  cancelFetch(self)
Closes the underlying AdaptorChannel, cancels the pending fetch, and resets/flushes all internal state.
  databaseContext(self)
Returns the DatabaseContext which pilots the DatabaseChannel.
  fetchesRawRows(self)
  fetchObject(self)
channel.fetchRow
  isFetchInProgress(self)
  isLocking(self)
Tells whether the fetched objects should be locked or not.
  isRefreshingObjects(self)
Tells whether the fetched objects should be refreshed or not.
  selectCountObjectsWithFetchSpecification(self, aFetchSpecification, anEditingContext)
Returns the number of rows that would be retrieved if the method selectObjectsWithFetchSpecification() was called with the same parameter.
  selectObjectsWithFetchSpecification(self, aFetchSpecification, anEditingContext)
The method follows the following steps:
  setCurrentEditingContext(self, anEditingContext)
This is automatically called by selectObjectsWithFetchSpecification()
  setCurrentEntity(self, anEntity)
This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.
  setFetchesRawRow(self, aBool)
This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.
  setIsLocking(self, isLocking)
This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.
  setIsRefreshingObjects(self, isRefreshingObjects)
This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.

Method Details

__init__(self, aDatabaseContext)
(Constructor)

Initializes a new DatabaseChannel and registers it with 'aDatabaseContext'.

It also creates its own AdaptorChannel to work with, by sending to aDatabaseContext.adaptorContext() the message createAdaptorChannel().

The following properties: currentEntity, isLocking() and isRefreshingObjects() are reset each time the method selectObjectsWithFetchSpecification() is called, according to the FetchSpecification settings.

adaptorChannel(self)

Returns the underlying concrete AdaptorChannel.

cancelFetch(self)

Closes the underlying AdaptorChannel, cancels the pending fetch, and resets/flushes all internal state.

databaseContext(self)

Returns the DatabaseContext which pilots the DatabaseChannel.

fetchObject(self)

  • channel.fetchRow
  • build GlobalID

Posts ObjectsChangedInStoreNotification (updated) if isRefreshingObjects

If no more object is to be fetched, it resets the DatabaseChannel and returns None.

Note that if the object fetched is already registered within the Database, its snapshots is not refreshed, and it is substituted to the fetched row (unless the fetch isRefreshingObjects)

See also: cancelFetch(), selectObjectsWithFetchSpecification()
Entity.globalIDForRow()

isLocking(self)

Tells whether the fetched objects should be locked or not.

If the DatabaseChannel has no fetch in progress, it returns false.

See also:
selectObjectsWithFetchSpecification, FetchSpecification.locksObjects()

isRefreshingObjects(self)

Tells whether the fetched objects should be refreshed or not.

See also:

  • selectObjectsWithFetchSpecification,
  • FetchSpecification.refreshesRefetchedObjects()

selectCountObjectsWithFetchSpecification(self, aFetchSpecification, anEditingContext=None)

Returns the number of rows that would be retrieved if the method selectObjectsWithFetchSpecification() was called with the same parameter.

Parameters:

aFetchSpecification -- a FetchSpecification object describing the
objects to be fetched

anEditingContext -- optional (since objects are not really fetched)

See also: selectObjectsWithFetchSpecification(),
EditingContext.objectsCountWithFetchSpecification() DatabaseContext.objectsCountWithFetchSpecification() AdaptorChannel.rowCountForSelectAttributes()

selectObjectsWithFetchSpecification(self, aFetchSpecification, anEditingContext)

The method follows the following steps:

  1. sets the object's properties according to aFetchSpecification's properties, i.e.: currentEditingContext, currentEntity, isLocking, isRefreshingObjects, etc.
  2. Opens its AdaptorChannel, if needed, then sends it the appropriate 'selectAttributes' message.

Fetched objects can be then retrieved one after the other by calling the method fetchObject().

Inheritance and 'isDeep' flaf of aFetchSpecification: Note that aFetchSpecification's entity is the real destination entity for the fetched objects, not one of its superclasses. Inheritance is handled at a higher level, i.e. in DatabaseContext.objectsWithFetchSpecification(). The 'isDeep' flag is completely ignored.

See also: fetchObject(), selectCountObjectsWithFetchSpecification()
AdaptorChannel.selectAttributes() EditingContext.objectsWithFetchSpecification()

setCurrentEditingContext(self, anEditingContext)

This is automatically called by selectObjectsWithFetchSpecification()

setCurrentEntity(self, anEntity)

This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.

setFetchesRawRow(self, aBool)

This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.

setIsLocking(self, isLocking)

This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.

setIsRefreshingObjects(self, isRefreshingObjects)

This is automatically called by selectObjectsWithFetchSpecification(), according to the settings of the FetchSpecification the latter method got.

Generated by Epydoc 2.1 on Sat Mar 4 13:36:27 2006 http://epydoc.sf.net