[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Networking library



On Sat, Apr 11, 2009 at 10:17:35AM -0700, Patrick Mullen wrote:
> On Sat, Apr 11, 2009 at 2:55 AM, Chris McCormick <chris@xxxxxxxxxxxx> wrote:
> > Hi,
> >
> > On Fri, Apr 10, 2009 at 04:44:30PM -0700, Patrick Mullen wrote:
> >> Python2.6 comes with json.  Other than that, it is a small thing to include.
> >>
> >> The library seems to be built around json, so removing it as a
> >> dependency doesn't make much sense.
> >
> > Actually I don't think it would be a huge job to change the serialisation
> > method to something else, optionally. I'll have a look it and see. My only
> > concern is about security - I chose JSON serialisation over something like
> > pickling because there's no way a client can inject malicious code using JSON.
> > I wonder if there's some other safe, built-in, pythonic way of serialising data
> > structures that I don't know about?
> 
> True. You could probably make the serialization abstract and allow
> other methods, by plugging in a different Serializer class of some
> sort.  Other than json, yaml, xml, etc I don't know any other good
> serialization for python, and everything I can think of is a
> dependency. Maybe for easy testing it could work with repr/eval, but
> prefers json if it is there.  (Repr/eval can serialize the same
> dictionaries that json can, and I think it's a bit faster too, its
> just a bit more dangerous)

After talking to a friend who suggested a few different serialisation methods,
like gherkin, and rencode, I tried implementing a serialisation wrapper layer
that lets you choose how to serialise, but gherkin and rencode both didn't
produce the exact structures that went in, coming out, so I'm going to have to
work a bit harder. I will definately steer clear of repr/eval, but I might try
out the other snippet that was posted here. Hopefully I'll come up with
something faster and lighter than JSON, with the option to use JSON. Will post
back here if and when I get it working.

Thanks for your interest.

Best,

Chris.

-------------------
http://mccormick.cx