Hi all

What do you think about the following code example? Is there a more elegant 
way to be able to call a function with and without arguments?
How can I select the fields which shall be returned? I did try it in the 
.select(db.location.id, db.location.name) part, but the JSON output always 
contained all the fields.

Cheers
-Luca.

def read():

    if (request.args(0) == None):

        default_sort_order = [db.location.country, db.location.city, 
db.location.street_name, db.location.street_number, db.location.building, 
db.location.name]

        locations = db().select(orderby = default_sort_order)

        return dict(locations = locations)

    else:

        location = db(db.location.id == request.args(0)).select().first()

        return dict(location = location)

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to