-# access_time = datetime.ctime();
-# last_documents = request.session.get("wiki_last_docs", [])
-#
-# if name not in last_documents:
-# last_documents.insert(0, (name, access_time))
-
+ access_time = datetime.now()
+ last_documents = request.session.get("wiki_last_docs", {})
+ last_documents[name] = access_time
+
+ if len(last_documents) > MAX_LAST_DOCS:
+ oldest_key = min(last_documents, key = last_documents.__getitem__)
+ del last_documents[oldest_key]
+ request.session['wiki_last_docs'] = last_documents
+