how can I pass a parameter from the view get the return value from a function of controller?

34 views
Skip to first unread message

Lynn

unread,
Jul 24, 2019, 11:20:57 AM7/24/19
to web2py-users

It seems that i cannot call a function with a parameter of a controller from the view. 

António Ramos

unread,
Jul 24, 2019, 11:48:07 AM7/24/19
to web...@googlegroups.com
Can u elaborate a little more ?
Please show some code...

Em qua, 24 de jul de 2019 às 16:20, Lynn <lynn.w...@gmail.com> escreveu:

It seems that i cannot call a function with a parameter of a controller from the view. 

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/15b5735d-fbac-4679-a4ca-2864b1bc94f8%40googlegroups.com.

Rahul

unread,
Jul 25, 2019, 7:21:41 AM7/25/19
to web2py-users
Hey Lynn,
     Not sure if this is what you ask for - I am passing query values as parameters in the view here

#Sample Function in controller
def showmyimage():   
   # Some db query you want to see data for
    displayimage = db.tableName(request.args(0,cast=int)) or redirect(URL('index')) 
     
    return dict (dispimage=dispimage)

In view - showmyimage.html

<!-- you can utilize it in this way - For example it is an image that you want to serve on the page. somephoto is the field name where image is uploaded or something -->
<img src="{{=URL('download', args=displayimage.somephoto)}}" />

Rahul

Val K

unread,
Jul 25, 2019, 12:34:57 PM7/25/19
to web2py-users
Just place your function in the module and import it in the view
Reply all
Reply to author
Forward
0 new messages