-def document_detail(request, name, template_name = 'wiki/document_details.html'):
- try:
- document = storage.get(name)
- except DocumentNotFound:
- raise Http404
-
-# 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))
+@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()},
+ })
+
+
+@never_cache
+def document_text(request, name):
+ storage = getstorage()
+ document = storage.get_or_404(name)