Hello everyone, Before I go ahead and build a simple middleware for this myself, I would like to know if such a middleware already exists in the wild, so that I can prevent re-inventing the wheel. Here's an example, if nobody is following what the subject actually means:
Say I have a view that does not return a django.http.HTTPResponse object. Instead, it returns a dictionary or a file-like object. I would like said middleware to detect this and format the output data accordingly. In the case of a dictionary, it will automatically add a JSON header, encode the dictionary and output it. For the sake of a file-like object, it will use it's .read() method to provide the output data. I would also like it to check if a Form object is being returned and automatically provide a template and a RequestContext. According to a DRY principle, this type of feature only makes sense to have built into Django. However, if I attempt to return anything but an HTTPResponse object, I get a big fat exception saying that it just won't work, and I need to manually construct my HTTPResponse object specifically for my data. Constructing HTTPResponses and Contexts is one of my most hated parts of Django, it's not really fun and get's very repetitive and old really fast. Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.