> > On 2011/7/14 greenmoss <[email protected]> wrote: > Let me preface my response by saying that I'm inexperienced, so I > could well be taking a suboptimal approach. That being the case, the > most logical way to handle game and graphics data for an in-game > object would IMHO be to attach it to a single python object. This in > turn leads to manual getstate/setstate overrides, extra code, etc. > > Is there some other way that people handle this type of situation? >
That is certainly not an unreasonable way to structure a game, but as you have become aware, it has various drawbacks when it comes to serialisation. I prefer to maintain a very strict Model-View-Controller separation in my code, to allow serialisation to be restricted to only data, which is fully separated from behaviour. On Thu, Jul 14, 2011 at 12:41 PM, Peter Enerccio <[email protected]> wrote: > Also, do not use pickle, its insecure. > That statement is at best misleading - there is no such thing as a 'secure' way to write data to the filesystem. Even were one to apply encryption, the program would need to have the decryption key in order to read it again, and that key could be trivially read from the source file or even from the running program in memory. The only reason that the python documentation issues the following warning: "*The pickle module is not intended to be secure against erroneous or maliciously constructed data. Never unpickle data received from an untrusted or unauthenticated source*", is that it is possible to hand-craft a file that will crash the unpickle process. In other words, only unpickle data that you had previously pickled yourself. -- Tristam MacDonald System Administrator, Suffolk University Math & CS Department http://swiftcoder.wordpress.com/ -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en.
