On 5/12/07, Nic James Ferrier <[EMAIL PROTECTED]> wrote: > > Eugene Morozov <[EMAIL PROTECTED]> writes: > > >> - there is proper separation between data and style, my JSON doesn't > >> include any stylistic information, only stuff that describes the data > > > > I still think that your example is not the best. "div" and "span" has > > no semantic meaning, they're just HTML placeholders. > > Well, ok. The reason for them is that you need them for structure. It > doesn't make sense to use another tag for some arbitary POSH. > > > >> - you get to use XSLT to turn the JSON into anything you want... you > >> need Atom from a resource as well as HTML? Just have 2 different > >> stylesheets but the same JSON. > > > > I think it is possible with plain Django templates, too. Just define 2 > > different templates. > > But then you're doing the python logic bits (for example, serializing > a seqence) more than once. With mine you only do the programming-y > bits once and then use XSLT to transform to whatever. The templates > are very simple then. I've used this approach in a couple of > frameworks.
I'm not sure I see the benefit of this approach to the typical django style. def my_view(request, template): context = {'some_list': ClassOne.objects.all(), 'some_other_list': ClassTwo.objects.filter(blah='whatever'), } return render_to_response(template, context) now I can pass the view any template I want, and it will send that contex to it. This template could very well be an XML document or a Latex document or whatever, it doesn't matter. In your example I would need to write an XSLT to transform the XML created into X. in the django way you you explicitly designate X. Creating an XSLT to do that is fine and all but it seems to add a layer of indirection, and one more added complexity to an already simple solution. ~ Anders > > > Your small framework could be really useful in some situations, I was > > just thinking about how to apply my XSLT knowledge to ease web > > development tasks. But I think that need better examples really > > showing benefits of XSLT approach. I was turned off by those HTML > > elements in JSON data immediately. Maybe this is just my personal > > opinion. > > Maybe... I'm not sure what upsets you about them really. > > The exact language you use is up to you... you can put whatever you > like in and it'll get turned into XML. > > For example, this would output something like ATOM: > > tfxslt.send_json(HttpResponse(), > {"feed": > [{"author": > {"email": "[EMAIL PROTECTED]"}}, > {"published": "Sat May 12 22:57:26 BST 2007" }, > [{"item": > {"summary": "a bit about this item"}}]]}, > "atom") > > And of course... if you've got anything that can serialize any other > data structure to JSON then you can use that as well. > > I'm really busy actually using my stuff at the mo... I'm hoping to try > and post it over this weekend on snippets. > > -- > Nic Ferrier > http://www.tapsellferrier.co.uk > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---