changeset 1438:f89fffd81540

Add ptime meta key to blog post items, logo and supertags meta keys to blog home items.
author Pavel Sviderski <pavel@psviderski.name>
date Thu, 24 May 2012 02:56:54 +0400
parents 359d51f0fa90
children df07ed7d4f3a
files MoinMoin/constants/keys.py MoinMoin/storage/middleware/indexing.py
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/constants/keys.py	Sun May 20 16:46:22 2012 +0200
+++ b/MoinMoin/constants/keys.py	Thu May 24 02:56:54 2012 +0400
@@ -81,6 +81,12 @@
 RESULTS_PER_PAGE = "results_per_page"
 DISABLED = "disabled"
 
+# keys for blog homepages
+LOGO = "logo"
+SUPERTAGS = "supertags"
+# keys for blog posts
+PTIME = "ptime"
+
 # index names
 LATEST_REVS = 'latest_revs'
 ALL_REVS = 'all_revs'
--- a/MoinMoin/storage/middleware/indexing.py	Sun May 20 16:46:22 2012 +0200
+++ b/MoinMoin/storage/middleware/indexing.py	Thu May 24 02:56:54 2012 +0400
@@ -78,6 +78,7 @@
                             LANGUAGE, USERID, ADDRESS, HOSTNAME, SIZE, ACTION, COMMENT, SUMMARY, \
                             CONTENT, EXTERNALLINKS, ITEMLINKS, ITEMTRANSCLUSIONS, ACL, EMAIL, OPENID, \
                             ITEMID, REVID, CURRENT, PARENTID, \
+                            PTIME, \
                             LATEST_REVS, ALL_REVS, \
                             CONTENTTYPE_USER
 from MoinMoin.constants import keys
@@ -106,9 +107,10 @@
     doc = dict([(str(key), value)
                 for key, value in meta.items()
                 if key in schema])
-    if MTIME in doc:
-        # we have UNIX UTC timestamp (int), whoosh wants datetime
-        doc[MTIME] = datetime.datetime.utcfromtimestamp(doc[MTIME])
+    for TIME in [MTIME, PTIME]:
+        if TIME in doc:
+            # we have UNIX UTC timestamp (int), whoosh wants datetime
+            doc[TIME] = datetime.datetime.utcfromtimestamp(doc[TIME])
     doc[NAME_EXACT] = doc[NAME]
     doc[WIKINAME] = wikiname
     doc[CONTENT] = content
@@ -265,6 +267,12 @@
         }
         latest_revs_fields.update(**userprofile_fields)
 
+        blogpost_fields = {
+            # publish time from metadata (converted to UTC datetime)
+            PTIME: DATETIME(stored=True)
+        }
+        latest_revs_fields.update(**blogpost_fields)
+
         all_revs_fields = {
             ITEMID: ID(stored=True),
         }
@@ -973,7 +981,7 @@
             # we have a result document from whoosh, which has quite a lot
             # of the usually wanted metadata, avoid storage access, use this.
             value = self._doc[key]
-            if key == MTIME:
+            if key in [MTIME, PTIME]:
                 # whoosh has a datetime object, but we want a UNIX timestamp
                 value = utctimestamp(value)
             return value