Changeset 3593
- Timestamp:
- 11/03/07 05:55:10 (9 months ago)
- Files:
-
- branches/1.1/CHANGELOG.txt (modified) (1 diff)
- branches/1.1/turbogears/paginate.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/CHANGELOG.txt
r3580 r3593 28 28 * Introduction of tg.mochikit_suppress to prevent the inclusion of 29 29 the shipped MochiKit 1.3.1. That allows to include custom mochikit versions. 30 * Ticket #1601. Workaround in paginate for databases without OFFSET. 30 31 31 32 *Fixes* 32 33 * Ticket #1595. Fixed broken quickstart change. 34 35 *Contributors* 36 37 Joel Pearson 33 38 34 39 1.0.4b2 (October, 27, 2007): branches/1.1/turbogears/paginate.py
r3528 r3593 31 31 32 32 log = logging.getLogger("turbogears.paginate") 33 34 # lists of databases that lack support for OFFSET 35 # this will need to be updated periodically as modules change 36 _so_no_offset = 'mssql maxdb sybase'.split() 37 _sa_no_offset = 'mssql maxdb access'.split() 38 39 # this is a global that is set the first time paginate() is called 40 _simulate_offset = None 33 41 34 42 def paginate(var_name, default_order='', default_reversed=False, limit=10, … … 201 209 endpoint = offset + limit_ 202 210 log.debug("slicing data between %d and %d", offset, endpoint) 203 output[var_name] = var_data[offset:endpoint] 211 212 global _simulate_offset 213 get = turbogears.config.get 214 if _simulate_offset is None: 215 _simulate_offset = get('paginate.simulate_offset', None) 216 if _simulate_offset is None: 217 _simulate_offset = False 218 so_db = get('sqlobject.dburi', 'NOMATCH:').split(':', 1)[0] 219 sa_db = get('sqlalchemy.dburi', 'NOMATCH:').split(':', 1)[0] 220 if so_db in _so_no_offset or sa_db in _sa_no_offset: 221 _simulate_offset = True 222 log.warning("simulating OFFSET, paginate may be slow") 223 log.warning("to turn off, set " 224 "paginate.simulate_offset=False") 225 226 if _simulate_offset: 227 var_data_iter = iter(var_data[:endpoint]) 228 # skip over the number of records specified by offset 229 for i in range(offset): 230 var_data_iter.next() 231 # return the records that remain 232 output[var_name] = list(var_data_iter) 233 else: 234 output[var_name] = var_data[offset:endpoint] 204 235 205 236 return output