in my controller: def view_searches: if db(db.post).isempty(): db.post.insert(message="Hi, it's" +' ' +auth.user.first_name+' '+ 'loging in...') form = SQLFORM(Post, formstyle='table3cols',) if form.process().accepted: pass long code... replies = db(db.answers.author == auth.user.id ).select(db.answers.ALL)[-5:5] return dict(form = SQLFORM(Post, formstyle='table3cols',).process(), replies = db(db.answers.author == auth.user.id ).select(db.answers.ALL)[-5:5])
html page: {{extend "layout.html"}} {{=LOAD('replies','view_searches.load',ajax=True)}} error message on loading view_searches.html: invalid controller (replies/view_searches) This is how far I've come On Mon, Nov 13, 2017 at 9:18 AM, Maurice Waka <mauricew...@gmail.com> wrote: > Sorry I cant make any head, nor tail of this.I need you help > > On Mon, Nov 13, 2017 at 8:13 AM, Maurice Waka <mauricew...@gmail.com> > wrote: > >> I don't have it. >> Let me work it out >> >> On Sun, Nov 12, 2017 at 10:33 PM, Dave S <snidely....@gmail.com> wrote: >> >>> >>> >>> On Saturday, November 11, 2017 at 7:13:31 PM UTC-8, Maurice Waka wrote: >>>> >>>> Why I said that: >>>> >>>> 1. Loading takes too long to load >>>> 2. I get an error: invalid controller..see below >>>> 3. >>>> >>>> >>>> >>>> >>> Loading takes too long? the LOAD helper should be faster than a page >>> refresh, give or take a cache hit. >>> >>> Do you have the file my-chatbot-app/controllers/messages.py, and does >>> it have the function answers() ? >>> >>> /dps >>> >>> >>> >>>> On Sat, Nov 11, 2017 at 1:58 PM, Maurice Waka <mauri...@gmail.com> >>>> wrote: >>>> >>>>> Thanks for the reply and details. It will take me several weeks juts >>>>> to get something to work out. As I had said, am not an expert in this as I >>>>> do part time programming; I have to study it first then practice till I >>>>> get >>>>> something to work out. >>>>> Is it OK if you give me a working example?...😜 >>>>> Kind regards >>>>> >>>>> On Sat, Nov 11, 2017 at 9:32 AM, Dave S <snide...@gmail.com> wrote: >>>>> >>>>>> >>>>>> >>>>>> On Friday, November 10, 2017 at 1:30:40 AM UTC-8, Maurice Waka wrote: >>>>>>> >>>>>>> Hi everyone. >>>>>>> For several months, though not a python expert, nor a web2py guru >>>>>>> either, I have been working on a simple bot. I borrowed from this site: >>>>>>> https://codepen.io/pavel_komiagin/pen/gaGJJK >>>>>>> [...] >>>>>>> I also don't want page refreshed on posting the question, that it >>>>>>> works like other bots where the messages appear from the bottom as they >>>>>>> come in. Ifigured out that maybe as the page refreshes, that's when the >>>>>>> cursor moves first up then to the bottom of the page, then the message >>>>>>> appears. >>>>>>> I dont mind a new code or referral. >>>>>>> >>>>>> >>>>>> That "append to the current page" stuff is ajax. Web2py has a very >>>>>> handy wrapper for ajax, the LOAD() helper. >>>>>> <URL:http://web2py.com/books/default/chapter/29/12/component >>>>>> s-and-plugins#LOAD> >>>>>> The target argument specifies where on the page to put the results >>>>>> ... you need a DIV that matches. >>>>>> >>>>>> My example, which goes in the view file: >>>>>> >>>>>> {{=LOAD(c='myhosts', f='myhosts2.load', target='my_hosts', >>>>>> content="something's >>>>>> happening", ajax=True)}} >>>>>> >>>>>> >>>>>> To continually append more messages, instead of replacing old with >>>>>> new, you would need to have multiple DIVs, and point to a different DIV >>>>>> for >>>>>> each message. >>>>>> >>>>>> The above code will run automatically on initial page load, which you >>>>>> may or may not want, depending on whether you want messages from a >>>>>> previous >>>>>> visit to appear. >>>>>> >>>>>> I have done some stuff where I want a user to click a button to get >>>>>> more information, and so I fabricate an html string in the controller, >>>>>> put >>>>>> the string into the dict I return, and the view displays the string in >>>>>> the >>>>>> appropriate part of the page. >>>>>> >>>>>> The string includes something like this: >>>>>> >>>>>> dis_str = CAT(dis_str, TT(" "), >>>>>> A("mystuff list", _href=URL("mystuff.html", vars= >>>>>> dict(ipaddr=ipaddr, hnam >>>>>> e=hname, tdisk=index)), >>>>>> _style="visibility:visible", _id="stuffh"), >>>>>> TT("\n "), >>>>>> TAG.BUTTON('mystuff list', _type="button", _name= >>>>>> "val2controller", _value=val2controller, >>>>>> _onclick='$("#mystuff_div").html("updating >>>>>> ..");ajax("mystuff.load", ["val2controller"], "mystuff_div")', >>>>>> _style="display:none", _id="mystuffa")) >>>>>> >>>>>> I think you can manipulate the DIV name either server side or client >>>>>> side, but I haven't tested any code for that purpose. >>>>>> >>>>>> Server side: keep the name in the session object, update it on each >>>>>> load, and in the view/controller/response.load file use the DIV helper >>>>>> after you display your messages. This will end up nesting the DIVs, but >>>>>> I >>>>>> don't think that's a problem. Caveat coder. >>>>>> >>>>>> Client side: use javascript to tap into the onclick path, and insert >>>>>> a new DIV into the DOM, then use that DIV's name in the ajax call. You >>>>>> may >>>>>> have to go direct to ajax in this scheme, rather than using the LOAD >>>>>> helper. This will require a little more study, but look at the other >>>>>> material in the book's component chapter, and it may help you out. >>>>>> >>>>>> Note that using ajax requires that your users allow javascript from >>>>>> your site, and there are plenty of people reluctant to do that, but if >>>>>> they >>>>>> are going to trust your site they might as well trust your site. Using >>>>>> something like noscript gives them some confidence that they protected >>>>>> against cross-site scripting attacks, but they can whitelist your site to >>>>>> view your pages. (noscript is for firefox; I don't know the equivalent >>>>>> in >>>>>> other browsers, but chrome has some of the features built in but not as >>>>>> easily tuned.) >>>>>> >>>>>> Good luck! I hope this helps, and that I haven't fed you too much >>>>>> bogus information. >>>>>> >>>>>> /dps >>>>>> >>>>>> -- >>>>>> 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 a topic in >>>>>> the Google Groups "web2py-users" group. >>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to >>>>>> pic/web2py/eH5y3Yvz56Q/unsubscribe. >>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>> web2py+un...@googlegroups.com. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> >>>> -- >>> 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 a topic in the >>> Google Groups "web2py-users" group. >>> To unsubscribe from this topic, visit https://groups.google.com/d/to >>> pic/web2py/eH5y3Yvz56Q/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> web2py+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.