diff MoinMoin/themes/__init__.py @ 770:a4ec2c6f0bb7 pytest2

history: do not yield Revision objects, but directly result documents from whoosh we have all that global and local history view (and also the atom feed) needs in the whoosh index. the whoosh documents yielded are dicts with all stored fields. by just using that, we do not need to access the backend storage any more for displaying history (which was one of the reasons for the slow global history for wikis with many revisions). one small difference is rev.timestamp (UNIX timestamp) vs. doc[MTIME] (datetime object). added size, action, comment fields to whoosh indexes (needed for history display and also useful for other reasons). adjusted the tests (pytest 2) TODO: ACL checks for history? (this is a general thing we need to be careful with: not to expose index data that should not be exposed). removed unused "mountpoint" history() param. add utctimestamp() == inverse of datetime.utcfromtimestamp()
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 25 Aug 2011 23:09:06 +0200
parents 035656874a40
children 95d1033b7808
line wrap: on
line diff
--- a/MoinMoin/themes/__init__.py	Wed Aug 24 18:19:30 2011 +0200
+++ b/MoinMoin/themes/__init__.py	Thu Aug 25 23:09:06 2011 +0200
@@ -366,6 +366,17 @@
     return 'moin-mime-%s' % cls
 
 
+def utctimestamp(dt):
+    """
+    convert a datetime object (UTC) to a UNIX timestamp (UTC)
+
+    Note: time library writers seem to have a distorted relationship to inverse
+          functions and also to UTC (see time.gmtime, see datetime.utcfromtimestamp).
+    """
+    from calendar import timegm
+    return timegm(dt.timetuple())
+
+
 def setup_jinja_env():
     app.jinja_env.filters['shorten_item_name'] = shorten_item_name
     app.jinja_env.filters['contenttype_to_class'] = contenttype_to_class
@@ -387,6 +398,7 @@
                             'item_name': 'handlers need to give it',
                             'url_for_item': url_for_item,
                             'get_editor_info': lambda rev: get_editor_info(rev),
+                            'utctimestamp': lambda dt: utctimestamp(dt),
                             'gen': make_generator(),
                             })