[Modeling-cvs] ProjectModeling/Modeling FetchSpecification.py,1.4,1.4.2.1 CHANGES,1.86.2.1,1.86.2.2
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-03-17 12:32:09
|
Update of /cvsroot/modeling/ProjectModeling/Modeling In directory sc8-pr-cvs1:/tmp/cvs-serv8527 Modified Files: Tag: brch-0_9pre5-SQL_SortOrdering_and_LIMIT FetchSpecification.py CHANGES Log Message: FetchSpecification: added (set)fetchSlice(), getNext/PreviousSlice() Index: FetchSpecification.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/FetchSpecification.py,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** FetchSpecification.py 14 Mar 2003 11:40:08 -0000 1.4 --- FetchSpecification.py 17 Mar 2003 12:32:05 -0000 1.4.2.1 *************** *** 45,49 **** __implements__ = (IFetchSpecification,) ! def __init__(self, entityName, qualifier=None, sortOrderings=(), distinctFlag=0, deepFlag=0, hints={}): "Initializes the FetchSpecification" --- 45,49 ---- __implements__ = (IFetchSpecification,) ! def __init__(self, entityName, qualifier=None, sortOrderings=None, distinctFlag=0, deepFlag=0, hints={}): "Initializes the FetchSpecification" *************** *** 56,59 **** --- 56,62 ---- self.setIsDeep(deepFlag) self._fetchLimit=0 + self._fetchOffset=0 + self._currentPage=0 + #self._sortOrderings=() self._refreshesRefreshedObject=0 *************** *** 69,72 **** --- 72,92 ---- return self._fetchLimit + def fetchSlice(self): + return {'limit':self._fetchLimit, 'offset': self._fetchOffset} + + def getPreviousSlice(self): + if not self._currentPage: + raise ValueError, 'No page was previously set' + if self._currentPage==1: + raise ValueError, 'Already at page one' + self._currentPage-=1 + self.setFetchSlice(self._fetchLimit, page=self._currentPage) + + def getNextSlice(self): + if not self._currentPage: + raise ValueError, 'No page was previously set' + self._currentPage+=1 + self.setFetchSlice(self._fetchLimit, page=self._currentPage) + def isDeep(self): return self._isDeep *************** *** 85,91 **** def setFetchLimit(self, limit): ! assert(limit>=0) ! self._fetchLimit=limit def setIsDeep(self, deepFlag): self._isDeep=toBoolean(deepFlag) --- 105,130 ---- def setFetchLimit(self, limit): ! self.setFetchSlice(limit, offset=0) + __sFS_marker=[] + def setFetchSlice(self, limit, offset=__sFS_marker, page=__sFS_marker): + # Check arguments + if offset and page: + raise ValueError, 'Parameters offset and page are mutually exclusive' + if limit<0: + raise ValueError, 'limit should be a positive integer' + if offset and offset<0: + raise ValueError, 'offset should be a positive integer' + if page and page<=0: + raise ValueError, 'page should be a strictly positive integer' + + # back to real work + self._fetchLimit=limit + if offset is not self.__sFS_marker: + self._fetchOffset=offset + elif page is not self.__sFS_marker: + self._currentPage=page + self._fetchOffset=limit*(page-1) + def setIsDeep(self, deepFlag): self._isDeep=toBoolean(deepFlag) *************** *** 112,116 **** def sortOrderings(self): ! return self._sortOrderings def usesDistinct(self): --- 151,155 ---- def sortOrderings(self): ! return self._sortOrderings or () def usesDistinct(self): Index: CHANGES =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/CHANGES,v retrieving revision 1.86.2.1 retrieving revision 1.86.2.2 diff -C2 -d -r1.86.2.1 -r1.86.2.2 *** CHANGES 17 Mar 2003 12:28:47 -0000 1.86.2.1 --- CHANGES 17 Mar 2003 12:32:06 -0000 1.86.2.2 *************** *** 19,22 **** --- 19,25 ---- certain limited number of objects at a time. + + * FetchSpecification: added (set)fetchSlice(), getNext/PreviousSlice() + 0.9-pre-5 (2002/03/17) Project milestone -- no public release |