Changeset 869
- Timestamp:
- 05/22/07 08:42:30
- Files:
-
- SimpleBlog/branches/optimizations/content/blog.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
SimpleBlog/branches/optimizations/content/blog.py
r867 r869 260 260 return [f for f in self.getBRefs('AppearsIn') if self.portal_membership.checkPermission('View', f)] 261 261 262 def buildBatch(self, b_start ):262 def buildBatch(self, b_start, query, notlimited_len): 263 263 """Return batch for navigation""" 264 len = self._count() 264 #if 'getAlwaysOnTop' in query.keys(): 265 #query['getAlwaysOnTop']=1 266 #len1 = len(self.portal_catalog(**query)) 267 #query['getAlwaysOnTop']=0 268 if 'sort_limit' in query.keys(): 269 del query['sort_limit'] 270 total_len = len(self.portal_catalog(**query)) 271 else: 272 total_len = notlimited_len 265 273 ditems = self.getDisplayItems() 266 max_pages = len/ditems274 max_pages = total_len/ditems + (total_len%ditems and 1 or 0) 267 275 batch = [] 268 276 if max_pages: … … 296 304 except: 297 305 b_start = 0 298 ditems = self.getDisplayItems() 299 count = self._count() 300 if b_start > count: 301 b_start = count - (count % ditems) 302 elif b_start < 0: 306 if b_start < 0: 303 307 b_start = 0 304 else:305 b_start = (b_start % ditems)!=0 and (b_start/ditems)*ditems or b_start306 308 return b_start 307 309 … … 328 330 329 331 onBottom = list(self.portal_catalog.searchResults(query)) 330 batch = 'navigation' in query.keys() and self.buildBatch(b_start) or []331 332 #### cut the b_start when it is tooo large 332 333 333 itemsPerPage = self.getDisplayItems() 334 334 last = 0 … … 341 341 if join: 342 342 results = onTop+onBottom 343 batch = 'navigation' in query.keys() and self.buildBatch(b_start, query, len(results)) or [] 343 344 if b_start > 0: 344 345 if len(onBottom) == b_start: … … 348 349 return (results,last,batch) 349 350 else: 351 batch = 'navigation' in query.keys() and self.buildBatch(b_start, query, len(onBottom)) or [] 350 352 return (onTop, onBottom, batch) 351 353
