-def document_detail(request, name, template_name = 'wiki/document_details.html'):
- try:
- document = storage.get(name)
- except DocumentNotFound:
- document = Document(storage, name = name, text = '')
+@never_cache
+def document_detail(request, name, template_name='wiki/document_details.html'):
+
+ document = getstorage().get_or_404(name)
+
+ 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
+
+ return direct_to_template(request, template_name, extra_context={
+ 'document': document,
+ 'document_info': document.info,
+ 'document_meta': document.meta,
+ 'forms': {"text_save": DocumentTextSaveForm(), "add_tag": DocumentTagForm()},
+ })
+