Using Just One View

26 views
Skip to first unread message

Mehdi

unread,
Jun 20, 2017, 1:25:00 PM6/20/17
to pylons-discuss
Hi
I have few experiences with pyramid traversal and angularjs as front end. Now before starting my new project there's a question in my mind bugging me:
Is it a good practice to define and config just one view on server side for angularjs single-page-app?
Since my server app just feed client with json data and client app takes care of templates, showing proper urls in address bar and loading static resources,
so wouldn't it better to have just one view callable on server app to take care of every client request based on sent data?
for example:
// to get a customer with id=120 :
var params = {key: "customer", id:120};
$.ajax("get_data", params, {...});

// or get a customer order :
var params = {key: "customer_order", cid:120, oid:10};
$.ajax("get_data", params, {...});

And on server view:
def get_data(context, request):
    key = request.request.POST.get("key")
    if key == "customer":
        # call proper function
    elif key == "customer_order"

        ...


Reply all
Reply to author
Forward
0 new messages