[Zope] ZSQL Method Question

Carlson, Christopher W. Christopher.W.Carlson@ct.sgcna.com
Fri, 25 Feb 2000 08:28:53 -0600


Wonderful!  Thank you *so* much for your help--it worked like a charm.

--- Chris

-----Original Message-----
From: Hannu Krosing [mailto:hannu@tm.ee]
Sent: Thursday, February 24, 2000 5:30 PM
To: Carlson, Christopher W.
Cc: 'zope@zope.org'
Subject: Re: [Zope] ZSQL Method Question


"Carlson, Christopher W." wrote:
> 
> Following your recommendation, I get the following:
> 
> Zope has encountered an error while publishing this resource.
> 
> Error Type: AttributeError
> Error Value: __getslice__

after I added the __getslice__ operator to 
lib/python/Shared/DC/ZRDB/Results.py
it started working

both the def __getslice__(...  and self._brains=brains in __init__
are needed

the start of class Results would look like this:

class Results:
    """Class for providing a nice interface to DBI result data
    """
    _index=None

    def __getslice__(self,start_index,end_index):
        return Results((self.__items__,self._data[start_index:end_index]),
                       self._brains,
                       self._parent)

    def __init__(self,(items,data),brains=NoBrains, parent=None):

        self._data=data
        self.__items__=items
        self._parent=parent
        self._brains=brains
        self._names=names=[]


There could be better solutions, but if there are none, I would urge 
the DC folks to consider adding something similar to Zope.

------------------
Hannu