Sure enough.  So, I am thinking "out loud" here--what would be the
advantage of a function (or class) in the controller over a class in a
module?

1. Would I be able to get rid of the class and all of its attributes
because every variable in the single controller file is visible to all
functions?  Don't think so...   ...scope rules still apply within
functions in the controller.
2.  I wouldn't have to import gluon.  That doesn't seem like a big
deal once you remember you need to do so in a module.
3. I wouldn't have to pass in the database handle and the request
variable.  OK, this seems like a real advantage.
4.  My argument (to make the function NOT an action) would be a no-op
because of point 3.  Funky, but no big deal.
5. Is there a performance advantage?  Probably, since not having to
import gluon would save some time.  OK, while the app is so small it's
not noticeable, this would still be a real advantage.
6.  I'd probably still use a class instead of a function because I
need about 8-10 "arguments," which would be a pain to pass in the
function call.  So, I would probably still put up with the syntactic
overhead of a class and the instance variables.  So, this is a wash.
And I am assuming that variable scope is by function, not across the
controller file.

Am I thinking about this right?  It seems like a slight advantage to
put the class in the controller file.  It would make the controller
file bigger.  Small code files are a bit neater.

Thanks for your thoughts on this.  If nothing else, I got to learn OO
much better.


On Mar 26, 7:33 pm, pbreit <[email protected]> wrote:
> If the functions are in the same controller file, any functions in that
> file are available (I believe they must take at least one parameter to
> distinguish them from controllers that respond to page requests).

Reply via email to