Got it. In that case, you can still use exec -- you probably want to wrap 
it in a try/except. Here's what web2py does to execute all model, 
controller, and view code (using the restricted() function in 
restricted.py):

    try:
        if type(code) == types.CodeType:
            ccode = code
        else:
            ccode = compile2(code,layer)
        exec ccode in environment

I suppose you could import and call the restricted() function as well if 
you want.

Anthony

On Wednesday, August 29, 2012 5:15:35 PM UTC-4, lucas wrote:
>
> yes, you're right, i should be more clear sorry.  consider two text fields 
> in a table.  one is called view and the other controller.  the view has the 
> similar syntax we are used to, it is just stored in the table and row.  and 
> the controller, i want to be able to allow myself to enter any type of 
> python executable code, and arrive at a final returned dictionary filled 
> with keys and values.  some or all of the kv pairs can be passed to render 
> the view, and some and others may be used to move to another process to 
> create other output.  so i want to be able to code the controller field, 
> allow web2py to execute it, and finally return the dictionary so that it 
> can be further used in the view or other processes.  i know it is a bit 
> dynamic, and thus difficult to give more details, so i am hoping that that 
> is more clear.  let me know.  ok.  lucas
>

-- 



Reply via email to