I figure out that this is a nice way to access objects directly by the
request URL, no need to use the .load extension, and I got the same output
as I expect in shell.

example:

#########################################################################

def wrapper():
    div = DIV('wrapper',BR(),HR())
    otherdiv = DIV('This is another div')
    def function1():
        div = DIV('function 1',BR(),HR())
        return locals()

    #### This code below should be encapsulated ####
    from inspect import isfunction as __isfunction
    if not request.args(0) in locals():
        return locals()
    elif __isfunction(locals().get(request.args(0))):
        return locals().get(request.args(0),locals)()
    else:
        return locals().get(request.args(0),locals)

#########################################################################

When I call: http://127.0.0.1:8000/testapp/default/wrapper
I got normal web2py app returning the objects div and otherdiv (with
scaffold layout)

When I call: http://127.0.0.1:8000/testapp/default/wrapper/function1
I got function 1 div as expected

and when I call
http://127.0.0.1:8000/testapp/default/wrapper/div
I got the DIV object as HTML <div>wrapper<br /><hr /></div>

also for: http://127.0.0.1:8000/testapp/default/wrapper/otherdiv
<div>This is another div</div>

I found this usefull to return pure HTML callbacks, no need to use .load and
I got the same what web2py shows in shell with no aditional blank line.

Can I rely on that kind of behaviour, or this way of doing can change in the
future,? (perhaps for security reasons)

Reply via email to