[orm-devel] Proposal datasource selectResult

Latzer Nico Nico.Latzer at R-KOM.de
Fri Jul 16 13:06:36 CEST 2004


maybe it would be useful for others too, if one could use a specialized
selectResult-Klass
sth. like

class mySelectResult(datasource.selectResult):
	def afterfetch(self, o):
		return o.__class__.__bases__.mangled()

ds=datasource()
ds._selectResult=mySelectResult


Example Implementation (datasource.py):
class datasource_base:
      ...
      _selectResult=None
      def runSelect(self, dbclass, query):
          """
          Common stuff from rselect and selectByClause
          """        
          cursor = self.execute(query)
!         x = self._selectResult or selectResult 
!         result = x(self, dbclass, cursor)
          return result

class selectResult
      ...
-     def afterfetch(self, o): #do sth with the ob, default to leave
unchanged
-       return o
      def fetchone(self):
          """
          Return a new instance of dbclass constructed from the data
returned
          by a fetchone() call on our cursor. Return None if ther're no rows
          left.
          """
!         return self.afterfetch(..
       def fetchall(self): #similar

Regards,
--Nico



More information about the orm-devel mailing list