[Zope] ZSQL from Script not working with zope 2.4.0

belen@netcom.no belen@netcom.no
Fri, 28 Sep 2001 10:15:45 +0100


Hello,

I am having problems with this method. This is not working with Zope 2.4
but it does with Zope 2.3.

The query is supposed to return the sum of some values and I have 
called the column 'CountOfResultNo'. I have tried with another query 
that returns a single value and this one is working.
The only difference I can see between the two is that when I try to 
retrieve a sum, that is "virtual" data, in the sense that that figure 
is not stored in the database but the result of some calculations. On 
the other hand my other single result query retrieves something that is 
actually stored as data in the database. Can this be the problem?

def getData(self, RunNumber, MDP):
        
         
	try:
 
		count_res=self.SQL_CountofTestResults(RunNo=RunNumber, 
MinDispPriority=MDP)
				
	except:
		return None

	## Get the total number of results in this run
	fields2index={}
	fieldNames=count_res._schema.items()
	
	
	for i in range (len(fieldNames)):
            fields2index[fieldNames[i][0]]=fieldNames[i][1]
            
            
        countOfTestResults=count_res[i][fields2index['CountOfResultNo']]
        
        return countOfTestResults

And this is the error message I get:

Error Type: IndexError
Error Value: array index out of range

Traceback (innermost last):
  File C:\Zope\BELENS~1\lib\python\ZPublisher\Publish.py, line 223, in 
publish_module
  File C:\Zope\BELENS~1\lib\python\ZPublisher\Publish.py, line 187, in 
publish
  File C:\Zope\BELENS~1\lib\python\Zope\__init__.py, line 226, in 
zpublisher_exception_hook
    (Object: LockableItem)
  File C:\Zope\BELENS~1\lib\python\ZPublisher\Publish.py, line 171, in 
publish
  File C:\Zope\BELENS~1\lib\python\ZPublisher\mapply.py, line 160, in 
mapply
    (Object: DataforFie)
  File C:\Zope\BELENS~1\lib\python\ZPublisher\Publish.py, line 112, in 
call_object
    (Object: DataforFie)
  File C:\Zope\BELENS~1\lib\python\OFS\DTMLMethod.py, line 194, in 
__call__
    (Object: DataforFie)
  File C:\Zope\BELENS~1\lib\python\DocumentTemplate\DT_String.py, line 
544, in __call__
    (Object: DataforFie)
  File C:\Zope\BELENS~1\lib\python\DocumentTemplate\DT_Util.py, line 
230, in eval
    (Object: getDataForPie(325,5))
    (Info: getDataForPie)
  File <string>, line 2, in f
  File C:\Zope\BELENS~1
\lib\python\Products\ExternalMethod\ExternalMethod.py, line 281, in 
__call__
    (Object: getDataForPie)
    (Info: ((325, 5), {}, None))
  File C:\Zope\BelenSite\Extensions\getDataForPie.py, line 31, in 
getData
    (Object: LockableItem)
  File C:\Zope\BELENS~1\lib\python\Shared\DC\ZRDB\RDB.py, line 252, in 
__getitem__
IndexError: (see above)

Can someone tell me what the problem might be? 

Thanks 

Belen