LOAD in py4web

244 views
Skip to first unread message

RHC

unread,
Feb 23, 2020, 1:18:51 PM2/23/20
to web2py-users
HI,

I am beginning to experiment with py4web, I like the sound of it and I am looking to convert a web2py project to py4web to see how they compare.

It appears that the LOAD (helper?) that was available in web2py templates is not available in py4web. I was using this to populate part of a web page, I liked the way you had the option to use LOAD to call a separate URL (within the same app) and insert the result into your page before returning the page to the client.

What is the reason for the absence of LOAD in py4web? is there a recommended alternative method of achieving the same effect? I have used a mixture of ajax=True and ajax=False options for this feature.

Thanks,

Richard.

Val K

unread,
Feb 23, 2020, 7:02:01 PM2/23/20
to web2py-users
for server side you can
@action("foo")
@action.uses("foo.html")
def foo():
    return dict(...)

@action("bar")
@action.uses("bar.html")
def bar():
    return dict(foo_content = foo())

# bar.html
[[=XML(foo_content)]]


for the client side, I suppose, you have to do it by yourself using pure js or some lib (JQuery, axios, Vue.js ... )

Carlos Cesar Caballero

unread,
Feb 23, 2020, 7:40:06 PM2/23/20
to web...@googlegroups.com
Or maybe using something like https://github.com/MoOx/pjax

--
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/47d4dc6b-caa6-439a-bd1f-4913af352d63%40googlegroups.com.

Massimo Di Pierro

unread,
Feb 24, 2020, 1:31:36 AM2/24/20
to web2py-users
We can add it in utils. But before we do. Do other peopl find it useful? Is that a pattern we should encourage vs, for example, vue.js?

António Ramos

unread,
Feb 24, 2020, 12:39:53 PM2/24/20
to web...@googlegroups.com
I think LOAD should be gone and we should move this kind of interaction to the client part.
Also py4web should stick with server stuff and let client stuff integrate better an in a more independent way.
For me FORM / smartgrid should also be gone. Vuetify and buefy tables are awesome. dont try to compete with that because your are competing with the power of vuejs. Just ease the connection between the 2.
The problem i see with vuejs is working with vue components. Without the need for vue components maybe a simpler tool like 



Regards
António


 

--
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.

Christian Varas

unread,
Feb 25, 2020, 10:08:03 AM2/25/20
to web...@googlegroups.com
I think it can be usefull if you use another template not based in vue.

Cheers.

RHC

unread,
Feb 25, 2020, 4:14:41 PM2/25/20
to web2py-users
Just to confirm, will that call to foo(0 return the html generated using that function and it's template?

My view on the various follow up questions about LOAD is that we should use existing frameworks where possible rather than complicating py4web. The appeal of py4web is that it has less of it's own javascript which in web2py was awkward to work around if it didn't work the way you needed it to.

Dave S

unread,
Feb 26, 2020, 8:49:20 PM2/26/20
to web2py-users


On Tuesday, February 25, 2020 at 1:14:41 PM UTC-8, RHC wrote:
Just to confirm, will that call to foo(0 return the html generated using that function and it's template?

My view on the various follow up questions about LOAD is that we should use existing frameworks where possible rather than complicating py4web. The appeal of py4web is that it has less of it's own javascript which in web2py was awkward to work around if it didn't work the way you needed it to.



My take is that one of the selling points of web2py was "everything you need to get going"  (aka "everything is in the box"),
and I think both FORM and LOAD are key parts of that.  I think Massimo has thought quite a bit about modularity, so I'd expect that FORM (and any putative LOAD) would be easy to swap out.

That said, the pjax suggestion and the alpine suggestion are both intriguing to someone with minimal VUE/REACT/ANGULAR experience.


Dave
/dps


Carlos Costa

unread,
Feb 26, 2020, 10:32:20 PM2/26/20
to web2py-users
LOAD is a very cool thing! And beginners just say WOW when they can create ajax-like experience so easy.
But, IMO, it lacks some important features for modern apps, like error handling and history handling.

I have written some simple functions to help cover these things...

Another way I found very useful was to use unpolly.js. It's magic but makes me a little lazyer about getting things done with vue.js.
(BTW they created unpolly to avoid using things like vue, react, etc, really!)

I would like very much to use vue.js but I am still noob regarding how to use it with py4web.
Maybe we should really encourage vue.js and stuff alike... but an initial pattern would be cool.
And IMO it should be simple and very cleared stated in the docs.
So no one will miss LOAD.

Massimo Di Pierro

unread,
Feb 28, 2020, 1:22:35 AM2/28/20
to web2py-users
never heard of unpolly.js and cannot find it. Have a link?

AGRogers

unread,
Feb 28, 2020, 2:21:41 AM2/28/20
to web...@googlegroups.com

--
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.

Carlos Costa

unread,
Mar 4, 2020, 8:37:51 AM3/4/20
to web...@googlegroups.com
Sorry for the typo.
I want to make a welcome template based on unpoly soon.



--
At.

Carlos J. Costa
--------------------------------------------------------------
Cientista da Computação - Esp. Gestão em Telecom

Alexei Vinidiktov

unread,
Feb 6, 2022, 9:37:49 AM2/6/22
to web2py-users
Have you managed to make a welcome template based on Unpoly?

cdbaron

unread,
Feb 15, 2022, 4:47:24 PM2/15/22
to web2py-users
I have several projects with web2py and I have already started to study the possibility of migrating to py4web.

They are all rendered on the server side and for now I want to keep it that way.

I see some challenges that make me a little scared:

*LOAD
* A Helper: (many times with the callback parameter and others with _href)
* URL: With user_signature=True for links with callback

I use hundreds of times A and URL and a little less LOAD

For none of these functions or helpers have I found a direct replacement in py4web.

LOAD does not exist in py4web, A does not have the possibility of ajax calls with the callback parameter and URL is totally different in py4web.

It would be great to see some of this web2py magic carried over to py4web.

Jim S

unread,
Feb 16, 2022, 6:10:33 PM2/16/22
to web2py-users
See this thread for how to replicate LOAD in py4web - https://groups.google.com/u/1/g/py4web/c/EUpv9IRJ_eo/m/niHzrnR5AwAJ

In short, use load_and_trap from utils.js.

I was using this for a while but then transitioned to doing all my reactive-type functions using htmx.  https://htmx.org

Check out my py4web htmx demo - https://github.com/jpsteil/py4web_htmx_demo

or my sample SouthBreeze application https://github.com/jpsteil/southbreeze  for examples.

htmx is amazing

NOTE - demos might now work with the latest py4web from github.  There are some changes I need to apply to my code that I haven't gotten to yet.

Can anyone else address the "A" and "URL" questions?

-Jim

cdbaron

unread,
Feb 17, 2022, 10:59:34 AM2/17/22
to web2py-users
Thanks a lot.

I'll try load_and_trap, but I think htmx may be better. I will look at your applications.
Reply all
Reply to author
Forward
0 new messages