Skip to content

Instantly share code, notes, and snippets.

@gcr
Created January 16, 2009 22:06
Show Gist options
  • Save gcr/48166 to your computer and use it in GitHub Desktop.
Save gcr/48166 to your computer and use it in GitHub Desktop.
def new_chunk(self, **args):
"""
Adds a new chunk by the user into a certain document. The user
does not need to be subscribed to said document. Used like so:
http://localhost:8000/new_chunk?p=99&t=Hello+World
"""
cherrypy.session.acquire_lock()
assert self.is_logged_in(), "User is not logged in"
assert "doc_name" in args and "p" in args and "t" in args, "Bad request- please supply document name, position, and text."
d = self.gb.get_document_by_name(args['doc_name'])
assert d.is_subscribed(cherrypy.session['user']), "You must be subscribed to this document to do that."
d.new_chunk(cherrypy.session['user'], args['p'], args['t'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment