The FormRenderer idea is a good one. But how about generalised Renderer objects that take or inherit a template list, build a context and then can be passed around to fill in the details. Update-able at construction, processing or rendering, and able to be passed straight into another context for rendering?
Like: ---- from django.template import loader, Context def update_context(context, *dicts, **kwargs): for dict in dicts: context.update(dict) if kwargs: context.update(kwargs) return context class Renderer(object): "builds and renders a context" def __init__(self, templates = None, *dicts, **kwargs): "takes a list of templates, and any extra context" self.context = dict() self.update(*dicts, **kwargs).template = loader.select_template (templates or self.templates) def update_context(self, *dicts, **kwargs): "update the context that will be rendered" update(self.context, *dicts, **kwargs) return self def render(self, *dicts, **kwargs): "renders with any extra context, without updating, enabling flyweight, e.g. reuse by a widget in a form or a search result list." return self.template.render(update_context(Context (self.context), *dicts, **kwargs)) def __unicode__(self): "calls render so we can pass the renderer directly into another context, as if a string" return self.render() ---- Didn't test it. ;) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---