[Zope] ZSQL Method Question

Hannu Krosing hannu@tm.ee
Fri, 25 Feb 2000 01:30:13 +0200


"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