示例#1
0
    def POST(self):
        # And we need the following variables.
        # The defaults are provided below.
        input = web.input(source=None, message=None, title=None, url=None)

        renderer.addData('messages', 0)

        # We must have the following keys passed,
        # otherwise this is an invalid request.
        if not input.source or not input.title:
            # Fail with an error.
            renderer.addData(
                'error',
                'Missing required parameters - need at least source and title.'
            )
            return renderer.render('messages/send.html')

        source_keys = input.source.split(",")
        messages = []
        errors = []

        if len(source_keys) > 10:
            renderer.addData(
                'error', 'You can not send to more than 10 sources at a time.')

        # Try to make a message for each.
        for key in source_keys:
            try:
                messages.append(
                    UserMessage.from_web(key.strip(), input, web.ctx.ip,
                                         UserMessages))
            except ExceptionUserMessage, ex:
                errors.append(ex.args[0])
示例#2
0
文件: index.py 项目: firehot/notifry
	def POST(self):
		# And we need the following variables.
		# The defaults are provided below.
		input = web.input(source = None, message = None, title = None, url = None)

		renderer.addData('messages', 0)

		# We must have the following keys passed,
		# otherwise this is an invalid request.
		if not input.source or not input.title:
			# Fail with an error.
			renderer.addData('error', 'Missing required parameters - need at least source and title.')
			return renderer.render('messages/send.html')

		source_keys = input.source.split(",")
		messages = []
		errors = []

		if len(source_keys) > 10:
			renderer.addData('error', 'You can not send to more than 10 sources at a time.')

		# Try to make a message for each.
		for key in source_keys:
			try:
				messages.append(UserMessage.from_web(key.strip(), input, web.ctx.ip, UserMessages))
			except ExceptionUserMessage, ex:
				errors.append(ex.args[0])