# blobviews.py # January 2011, Kyle Miller import blobs from actionlist import ContinueWith, DeferAction, ActionList, action_assert, ActionTable from tornado.httpclient import HTTPError import uuid # # Definitions of view handlers # blob_views = ActionTable(doc="""These are views for individual blobs. The signature for each is (handler, blob, a_data) -> String""") blob_views.define_actionlist("show", doc="For rendering the blob to html.") blob_views.define_actionlist("edit", doc="For a blob edit view.") blob_views.define_actionlist("edit_post", doc="For posting from a blob edit view.") blob_views.define_actionlist("delete", doc="For a deleting a blob.") blob_views.define_actionlist("delete_post", doc="For actually deleting a blob.") blob_to_html = ActionList(doc="""This is to convert a blob to html. It is used by the show blob_view. It's separated so we can make a BlobModule for blobs""") blob_get_name = ActionList(doc="""This is to get a string identifier of a blob for a user to view. Not guaranteed to be unique!""") blob_create_view = ActionList(doc="""This is to construct a view for creating a new blob. This isn't a blob_view since we don't know the blob yet.""")
# bbviews.py # January 2011, Kyle Miller # # views of a blob base import blobs from actionlist import ContinueWith, DeferAction, ActionList, action_assert, ActionTable from tornado.httpclient import HTTPError import uuid # # Definitions of view handlers # bb_views = ActionTable(doc="""These are views for entire blob bases.""") bb_views.define_actionlist("recent_changes", doc="For showing what's recently been done to a blob.") @bb_views.add_action("recent_changes") def bb_views_recent_changes(handler, blob_base): entries = handler.db.doc.find({"blob_base": blob_base}).sort([("modified", -1)]) the_blobs = blobs.Blob.docs_to_blobs(handler.db, entries) handler.render("bbrecent_changes.html", blob_base=blob_base, the_blobs=the_blobs)
# docviews.py # January 2011, Kyle Miller import blobs from actionlist import ContinueWith, DeferAction, ActionList, action_assert, ActionTable from tornado.httpclient import HTTPError import uuid import blobviews # # Definitions of view handlers # doc_views = ActionTable(doc="""These are views for documents.""") doc_views.define_actionlist("show", doc="For showing a whole document (and all of its current versions).") doc_views.define_actionlist("history", doc="For showing the history of a document.") # # doc action: show # @doc_views.add_action("show") def docview_show_default(handler, doc_id) : entries = handler.db.tags.find({"_doc_id" : doc_id, "_masked" : False}).sort([("modified", -1)]) the_blobs = list(blobs.Blob.tags_to_blobs(handler.db, entries)) if not the_blobs : entries = handler.db.tags.find({"_doc_id" : doc_id}).sort([("modified", -1)]) the_blobs = list(blobs.Blob.tags_to_blobs(handler.db, entries)) if not the_blobs : raise HTTPError(404)