On Thu, Jul 16, 2009 at 3:12 AM, jfine<jonathan.fi...@googlemail.com> wrote:
>
> Hi
>
> Django can, of course, serialize database objects into JSON:
>    http://docs.djangoproject.com/en/dev/topics/serialization/
>
> I'd like to turn that JSON into JavaScript objects.  I'd like, of
> course, a Formula object to be turned into an 'instance of the Formula
> class'. (The quotes are because JavaScript doesn't really have classes
> and instances.)
>
> Django can also, of course, serialize a whole database into JSON.  A
> more ambitious task is to turn that JSON into a linked collection of
> database objects.
>
> Does this sound interesting? Has something like this been done
> already?

Sure, this _could_ be done. You can write and install custom
serializer - you just need to work out exactly how a random database
object is realized as a JavaScript object. The existing serializers
should give you a reasonable idea of how to do this.

Has it been done already? Not to my knowledge, but I won't claim to
have omniscient knowledge of the Django community. Google is your
friend.

Should it be done? I have a minor hesitation based around attack
vectors - when sending JSON, you're sending raw data, so the potential
for attacks is limited. However, if you're serializing objects with
the expectation that they will be executable as received, you've
opened up a door through which exploits could enter. Of course,
whether this is actually a problem depends very much on how you handle
the received objects. Caveat Emptor.

Also - keep in mind that from a Django perspective, a serializer is
only half the job. There is also the deserializer, for converting a
JavaScript object back into a database object. Of course, you may not
need this for your own bespoke purposes.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to