How to create wrapper / decorator functions

21 views
Skip to first unread message

Gilad Hoshmand

unread,
Jun 17, 2019, 7:08:11 AM6/17/19
to web...@googlegroups.com
Hi
I'm trying to create wrapper/decorator functions like so:

The view to load is the same html file every time, the args need to be different. 
I can pass arguments using request.args[0] etc. but it seems dirty and I prefer to separate and handle pre-processing the data (according to args) in the wrapping functions & then call the generalFunc.


def func1():
    var1
= ...
    var2
= ...
   
return genralFunc(var1 , var2 )


def func2():
    var1
= ...
    var2
= ...
    var3
= ...
   
return genralFunc(var1 , var2 , var3)


def generalFunc(a , b , c):
   
...dostuff...
   
return (dict( ...... all page data .....))


user calls controller/func1 => main_page.html
user calls controller/func2 => main_page.html

Each time with different data

Gilad Hoshmand

unread,
Jun 17, 2019, 7:26:34 AM6/17/19
to web...@googlegroups.com
This is the answer:
Call /controller/wrapper_func1/arg1/arg2

def wrapper_func1():
       
....get args...
        response
.view  =  "path/to/main_page.html"
       
return generalFunc(..args..)

Reply all
Reply to author
Forward
0 new messages