comparison roundup/date.py @ 4472:34dce76bb202

Multilink fixes and optimizations: - Optimisation: Late evaluation of Multilinks (only in rdbms backends): previously we materialized each multilink in a Node -- this creates an SQL query for each multilink (e.g. 'files' and 'messages' for each line in the issue index display) -- even if the multilinks aren't displayed. Now we compute multilinks only if they're accessed (and keep them cached). - Add a filter_iter similar to the existing filter call. This feature is considered experimental. This is currently not used in the web-interface but passes all tests for the filter call except sorting by Multilinks (which isn't supported by SQL and isn't a sane concept anyway). When using filter_iter instead of filter this saves a *lot* of SQL queries: Filter returns only the IDs of Nodes in the database, the additional content of a Node has to be fetched in a separate SQL call. The new filter_iter also returns the IDs of Nodes (one by one, it's an iterator) but pre-seeds the cache with the content of the Node. The information needed for seeding the cache is retrieved in the same SQL query as the ids.
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Mon, 21 Mar 2011 20:44:39 +0000
parents 605f31a596b8
children 6e3e4f24c753
comparison
equal deleted inserted replaced
4471:4f353d71d716 4472:34dce76bb202
247 is i18n module or one of gettext translation classes. 247 is i18n module or one of gettext translation classes.
248 It must have attributes 'gettext' and 'ngettext', 248 It must have attributes 'gettext' and 'ngettext',
249 serving as translation functions. 249 serving as translation functions.
250 """ 250 """
251 self.setTranslator(translator) 251 self.setTranslator(translator)
252 # Python 2.3+ datetime object
253 # common case when reading from database: avoid double-conversion
254 if isinstance(spec, datetime.datetime):
255 if offset == 0:
256 self.year, self.month, self.day, self.hour, self.minute, \
257 self.second = spec.timetuple()[:6]
258 else:
259 TZ = get_timezone(tz)
260 self.year, self.month, self.day, self.hour, self.minute, \
261 self.second = TZ.localize(spec).utctimetuple()[:6]
262 self.second += spec.microsecond/1000000.
263 return
264
252 if type(spec) == type(''): 265 if type(spec) == type(''):
253 self.set(spec, offset=offset, add_granularity=add_granularity) 266 self.set(spec, offset=offset, add_granularity=add_granularity)
254 return 267 return
255 elif isinstance(spec, datetime.datetime):
256 # Python 2.3+ datetime object
257 y,m,d,H,M,S,x,x,x = spec.timetuple()
258 S += spec.microsecond/1000000.
259 spec = (y,m,d,H,M,S,x,x,x)
260 elif hasattr(spec, 'tuple'): 268 elif hasattr(spec, 'tuple'):
261 spec = spec.tuple() 269 spec = spec.tuple()
262 elif isinstance(spec, Date): 270 elif isinstance(spec, Date):
263 spec = spec.get_tuple() 271 spec = spec.get_tuple()
264 try: 272 try:

Roundup Issue Tracker: http://roundup-tracker.org/