Mail archive

Re: [Acf] RFC: The controller.func( model ) syntax

From: Natanael Copa <>
Date: Wed, 18 Oct 2006 08:50:07 +0200

On Tue, 2006-10-17 at 19:21 +0000, Nathan Angelacos wrote:
> Natanael Copa wrote:
> > Hi,
> >
> > I was wondering if we could change the way the controllers are called.
> >
> > Instead of the current:
> >
> > func( model )
> >
> > Could we do:
> >
> > func( self, model )
> >
> > I think that would simlify some things.
> >
> > Thoughts?
> How will it simplify things? Can you give an example?

Its more like intuition... :)

You will get a more object oriented apporach and can reuse the

We could for example have standard controllers with standard function
and then reuse them.

It would also give the fron controller (or is it a front view?)
possibility to bypass variables to the controller rather than depending
on global vars (like FORM). In our environment it does not make any
difference since all we do is web, but how do you send variables if we
are using a CLI? will we need to convert the getopt to a http GET/POST
request and then send it via the global FORM variable?

You could also have controllers per object, lets say each network
interface gets their own controller.

eth0 = interface_controller:new()
eth0:set_ip( ipaddr )

Note that the difference is not that big really:

eth0 = {}
set_ip(eth0, ipaddr )
bring_up( eth0 )

The nice things is that we could have standard controllers for different
kind of things, like starting and stopping services and then just let
new thing inherit the funcs for other controllers. For example, most
services are started and stopped with /etc/init.d scripts. But what
about individual network interfaces? With object oriented approach you
could let the interface be a "service" ( it returns a status, you can
start it and you can stop it)

serivce = Object:new{
	name = nil,
	status = nil
function service:start()
	return os.execute( cf.dir.root .. "/etc/init.d/" .. name .. "start"
interface = service:new()
	os.execute( "ifup " .. )
After that each interface can be treated as an ordinary service. You get
status from it, you can start and stop it indiviually.
I gues I was working me a bit wrong. It does not necesarily make things
simple, it makes things much more flexible (which can help us making
things more simple at the end)
PS. You did notice you can treat almost all standard funcs as objects?
mystring = "Hello world"
print ( mystring:upper() )
view = {}
view:insert( { name = "test", type="textinput", value="enter textx here" } )
Natanael Copa
Received on Wed Oct 18 2006 - 08:50:07 UTC