Пример #1
0
	def process_form(form_class, request, **kwargs):
		CustomForm = form_class
		ids_format = "%s-%%s" % CustomForm.slug
		feedback = []
		
		if request != None and request.method == 'POST':
			form = CustomForm(request.POST, auto_id=ids_format)
			if form.is_valid():
				# Are there any form processors?
				if form.slug in FormsAPI.actions:
					actions = FormsAPI.actions[form.slug]
					for func in actions:
						feedback.append(func(form, **kwargs))
						
				# Carry out the actions applied to all forms with *
				# This and the above could be combined some day.
				if '*' in FormsAPI.actions:
					actions = FormsAPI.actions['*']
					for func in actions:
						feedback.append(func(form, **kwargs))

				debug("Submitted: %s" % form.slug)
				form = CustomForm(auto_id=ids_format)
		else:
			form = CustomForm(auto_id=ids_format)
		
		if kwargs.get("feedback") or False:
			# Remove empty feedback
			for k,v in enumerate(feedback):
				if not v:
					del feedback[k]
			return form, feedback
		else:
			return form
Пример #2
0
def form_debug(form, **kwargs):
	debug("Form debug: %s" % form.slug)