Exemple #1
0
		except Exception, e:
			ret['message'] = "<strong>FATAL</strong>(do_dropbox.user): %s" % e
		else:
			from main.tasks import process_web_action, get_success_msg
			try:
				process_web_action(user, request.POST)
			except Exception, e:
				ret['message'] = '<strong>FATAL</strong>: (%s) <br/>%s' %\
								 (action, e)
			else:
				ret['status'] = 'success'
				ret['task_id'] = "%s: (%s)" %\
								 (settings.TASK_SUCCESS, action, )
				ret['message'] = '<strong>SUCCESS</strong>: (%s) %s' %\
								 (action,
								  get_success_msg(request.POST), )
	else:
		ret['message'] = '<strong>FATAL</strong>(do_dropbox): Invalid Request'
	return HttpResponse(simplejson.dumps(ret), content_type="application/json")

@requires_csrf_token
def get_content_div(request):
	"""
	Render requested content for 'content div'
	Works a-la RPC: executes specified method from content.py
	and renders appropriate template from templates/content
	"""
	ret = { 'status': 'error', 'message': '', 'html': '' }
	if request.method == 'POST' and request.user:
		try:
			user = MDBUser.objects.get(username=request.user.username)
Exemple #2
0
			request['filename'] = self.get_argument('filename', None)
			request['action'] = self.get_argument('action')
			from main.tasks import process_web_action, get_success_msg
			try:
				yield gen.Task(process_web_action,
					user, request)
			except Exception, e:
				ret['message'] = '<strong>FATAL</strong>: (%s) <br/>%s' %\
								 (request['action'], e)
			else:
				ret['status'] = 'success'
				ret['task_id'] = "%s: (%s)" %\
								 (settings.TASK_SUCCESS, request['action'], )
				ret['message'] = '<strong>SUCCESS</strong>: (%s) %s' %\
								 (request['action'],
								  get_success_msg(request), )
		self.set_header("Content-Type", "application/json")
		self.write(ret)
		self.finish()

# Define the class that will respond to the URL
class FileSaveHandler(DjangoBaseHandler):
	"""
	Handles /async/save
	Updates specified file with new content from UI editor
	"""
	@web.asynchronous
	@gen.engine
	def post(self):
		ret = { 'status': 'error', 'message': '', 'task_id': '', }
		user = self.get_mdb_user()