Try Python update

Devan L devlai at gmail.com
Sun Jan 1 20:25:10 EST 2006


Mike Meyer wrote:
> "Devan L" <devlai at gmail.com> writes:
> >> If you want to try an online P{ython tool that lets you save code, try
> >> Devan L's at http://www.datamech.com/devan/trypython/trypython.py.
> > My code uses one of the recipes from the Python Cookbook, 7.6 Pickling
> > Code Objects. It's limited to closures though, just like in the recipe.
> > So uh, you can't write closures in mine.
>
> I don't have the dead trees version, and the online version doesn't
> have chapter numbers. Is that <URL:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/212565>?

It was one of the recipes of the day, actually. They don't keep them up
for more than a week, though, I think. But more or less it has all of
the attributes used for creating an object from types.CodeType in
correct order.

> > On a side note, my brother has tinkered with the C internals and now
> > __subclasses__ is restricted and many, many os and posix commands are
> > restricted (not that you can get them anyways, since importing is
> > broken!)
>
> I got import to work by pickling pairs of names - the variable name
> that references the module, and the name of the module. When it
> unpickles the list, it reimports them and points the appropriate
> variable at them. This had unwanted effects if you did an "import
> this". It also doesn't work for objects that contain references to
> modules.

My general method of storing is to store everything possible. See a
function? Store the function object itself. See a class? Store the
class object. Unfortunately, I can't store builtin methods or
functions, so this breaks on most modules. Don't try to reference the
__builtins__, by the way, otherwise it won't be removed and modjelly
will break.


> I tried for a bit to restrict things, then gave up and did it
> externally. There's no access to any files but those required to run
> the script that deals with thing, and some other python modules that I
> decided would be nice to have. Normally, nothing in the tree is
> writable, either. Once I'm happy with it, I'll save a copy of the tree
> somewhere and set up a cron job to "refresh" it at regular intervals.

I don't have enough control on the server to effectively restrict it
externally (no running as an unprivelleged user!), so I have to lock it
down as tightly as possible internally.




More information about the Python-list mailing list