Ejemplo n.º 1
0
def archiveMessage(parsed):
	log.log(log.DEBUG, 'Archiving message: ' + parsed['doc-tag'][0])
	# Use the UUID from the event or generate one if the event didn't specify
	if 'event-uuid' in parsed:
		uuid = parsed['event-uuid'][0]
	else:
		uuid = util.makeUUID()

	# Notification MUST be archived by UUID before any other format
	uuidArchive(uuid, parsed)

	for callback in archiveCallbacks:
		f = archiveCallbacks[callback]
		f(uuid, parsed)

	# Update the uuid cache
	notifier.uuidcache.insert(0, (uuid, 0))
	return (0, uuid)
Ejemplo n.º 2
0
def renderList(templateFile, uuidList):
	log.log(log.DEBUG, 'Rendering django list (' + templateFile + ')')
	
	# Turn a list of UUIDs into a list of tuples (tag, date)
	eventList = []
	for uuid in uuidList:
		parsed = archive.getArchived(uuid)
		if ('doc-tag' in parsed) and ('event-date' in parsed):
			eventList.append( (parsed['doc-tag'], parsed['event-date']) )
		else:
			log.log(log.ERROR, 'Missing doc-tag or event-date in archive (uuid:' + uuid + ')')

	# Read the template file
	template = ''
	fd = open(os.path.join(config.get('notifier', 'templatepath'), templateFile), 'r')
	template = fd.read()
	fd.close()

	# Create django objects and render
	template = django.template.Template(template)
	context = django.template.Context({'entries': eventList, 'updated': eventList[-1][1][0], 'feed_uuid': util.makeUUID()})
	return template.render(context)