>From this section: http://web2py.com/books/default/chapter/29/04/the-core#Dispatching
*Functions that take arguments or start with a double underscore are not > publicly exposed and can only be called by other functions.* > Anthony On Sunday, May 7, 2017 at 5:53:29 PM UTC-4, Matt Bockman wrote: > > When trying to figure out how to create a private function in a controller > I first searched the web2py book and I spent a good amount of time looking > for this. I eventually decided to search the Google group with success. > > My ability to search/browse the web2py book is getting better but I'm > still very new at it. Is this convention documented in the web2py book? I > was looking in "the core" but I didn't find what I needed there. How can > this be added and where would it go? > > Thanks, > Matt > > On Sunday, March 16, 2008 at 2:40:14 PM UTC-7, Massimo Di Pierro wrote: >> >> Done in trunk! >> >> Massimo >> >> On Mar 16, 2008, at 4:07 PM, voltron wrote: >> >> > >> > YESSS! Cool! I am for that :-)) >> > >> > On Mar 16, 9:55 pm, Massimo Di Pierro <mdipie...@cs.depaul.edu> wrote: >> >> double underscore I can do. ;-) >> >> >> >> Massimo >> >> >> >> On Mar 16, 2008, at 11:13 AM, voltron wrote: >> >> >> >> >> >> >> >>> I just noted that I voted for the wrong convention: >> >> >> >>> yes for double underscores "__" not for a single underscore "_" >> >> >> >>> :-) >> >> >> >>> On Mar 16, 5:04 pm, voltron <nhy...@googlemail.com> wrote: >> >>>> Hmm, I'm not sure Massimo, Imho, I would always consider a well >> >>>> known >> >>>> and defined Pythonic convention( everybody that uses Python >> >>>> knows the >> >>>> double underscore convention), I am sure that all of the new web2py >> >>>> users like myself made the same mistake when trying to create >> >>>> private >> >>>> functions, this is a good thing:-) ! It would not even have to be >> >>>> documented because its naturally pythonic, on the other hand we >> >>>> have a >> >>>> handful of users( judging from the number of registered users) >> >>>> and an >> >>>> AJAX convention that is not universal and self descriptive, i.e, >> >>>> just >> >>>> seeing a function called "_sendData" would not notify me >> >>>> immediately >> >>>> that it is an AJAX function, I would have done this, "ajax_sendData >> >>>> ()" >> >>>> which is self descriptive. >> >> >> >>>> I really respect the principle of not breaking Web2py, but is this >> >>>> not >> >>>> a bit too early for that? Web2py is very young and probably not so >> >>>> widely deployed as the other frameworks, so this would be a >> >>>> chance to >> >>>> quickly implement such changes. Even Python itself would implement >> >>>> code-breaking changes soon, most frameworks undergo such changes >> >>>> too, >> >>>> it is evolution. I seriously doubt that you would drive users away >> >>>> when such changes are made, on the contrary. I think many would >> >>>> like >> >>>> web2py even more, I would definitely. >> >> >> >>>> I respect your opinion, but if you are uncertain, why not poll the >> >>>> forum? You would know if people are against the changes then >> >> >> >>>> On Mar 16, 4:23 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: >> >> >> >>>>> correction.... use >> >> >> >>>>> if request.function[0]=='_' and not request.function=='_TEST': >> >>>>> raise >> >>>>> HTTP(400,'some error') >> >> >> >>>>> since _TEST is the name of a "virtual" function called by admin >> >>>>> when >> >>>>> you click on [test] It is automatically generated when testing. >> >> >> >>>>> Massimo >> >> >> >>>>> On Mar 16, 10:20 am, mdipierro <mdipie...@cs.depaul.edu> wrote: >> >> >> >>>>>> The more I think about this the more I see a problem. Some >> >>>>>> people for >> >>>>>> example are using the leading _ to indicate a controller >> >>>>>> function used >> >>>>>> for an ajax callback. In order to do what you asked I would break >> >>>>>> their code. Even without breaking code people would still need to >> >>>>>> upgrade the admin app to see the effects. This would break my >> >>>>>> promise >> >>>>>> of backward compatibility. Why don't you simply say, at the >> >>>>>> top of >> >>>>>> your controller? >> >> >> >>>>>> if request.function[0]=='_': raise HTTP(400,'some error') >> >> >> >>>>>> and so you set your own convention. >> >> >> >>>>>> Massimo >> > > >> >> -- 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.