Hi gasolin,

There is no real reason to maintain the module declaration if you can
be assured that no other variable or function will overwrite expose.
In your sample, there isn't a problem.  But, cherrypy has an expose
method, so if you did:

from turbogears import expose, controllers
from cherrypy import *

class Root(controllers.RootController):
    @expose()
    def index(self):
        return "Hello World!"

You would be using cherrypy.expose, rather than turbogears.expose.

Generally speaking it's probably best not to use import * unless you
are sure of what that will bring in to your namespace.

And hey, if you are just going for sheer brevity:

from turbogears import expose as e, controllers as c
class R(c.RootController):
    @e()
    def index(s):
        return "Hello World!"

Now I've thrown down the gauntlet, and someone will be sure to
implement this in two lines. :-)

Reply via email to