¿Cómo ejecutar scripts dinámicos de Python en tiempo de ejecución?

I am trying to get two aspects worked out :

  1. First how do I run python script stored in DB as a BLOB in sandbox mode (maybe using PyPy sandbox)?
  2. Secondly how can I generate the script itself from the code template (the code template been saved as BLOB in DB) and serve it with the required data ?

Cualquier ayuda con esto sería genial. Gracias.

preguntado el 31 de enero de 12 a las 08:01

2 Respuestas

  1. Puede usar el eval (). But beware of security holes!
  2. Please post your tempate code.

Respondido el 31 de enero de 12 a las 12:01

Correct me if I am wrong but you can't pass a script to eval() function. Instead execfile() does but doesn't let you import. I have gone through this enlace but here it fetches from an URL instead of a BLOB. - Zakiullah Khan

compile(source, filename, mode[, flags[, dont_inherit]])

Compile the source into a code or AST object. Code objects can be executed by an exec statement or evaluated by a call to eval(). source can either be a string or an AST object. Refer to the ast module documentation for information on how to work with AST objects.

Respondido el 31 de enero de 12 a las 13:01

@syntesizerpatel Thanks, will look into it. - Zakiullah Khan

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.