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

Class result

source code

This is the base class for all results. A result is a collection of one kind of dbobjects that have been retrieved from the database. This class will emulate a sequence but also has a next() method like a generator (so I don't have to change all that code that assumes a result to be a generator). The result class also has two methods to determine the result's length by querying the database. If you need to traverse over a result more than once, you must cast it into a list (and by that copying all dbobjects to the client's memory).

The result class needs to deal with datasources that have an attribute called no_fetchone set, that makes this class use the cursor.fetchall() method (most notable for the gadfly adapter).

Instance Methods [hide private]
  __init__(self, ds, dbclass, select)
  __iter__(self)
  next(self)
  fetchone(self)
  count(self)
This is a helper function that will perform a query as SELECT COUNT(*) ...
  count_all(self)
This is a helper function that will perform a query as SELECT COUNT(*) ...

Method Details [hide private]

__init__(self, ds, dbclass, select)
(Constructor)

source code 
Parameters:
  • ds - Datasource object
  • dbclass - dbclass object of whoes instances this result will be
  • select - orm2.sql.select instance of the query

__iter__(self)

source code 
None

next(self)

source code 
None

fetchone(self)

source code 
None

count(self)

source code 

This is a helper function that will perform a query as

   SELECT COUNT(*) ...

appropriate to determine the number of rows in this result.
This will remove all clauses of the original select except the
WHERE clause.

This can't be called __len__(), because then it is used by
list() and yields a superflous SELECT query.

count_all(self)

source code 

This is a helper function that will perform a query as

   SELECT COUNT(*) ...

appropriate to determine the number of rows in this result.
This will remove all clauses of the original select except the
WHERE clause.

This can't be called __len__(), because then it is used by
list() and yields a superflous SELECT query.