Bill Mill wrote:
> Hmmm... I guess I thought there was going to be a
better way to do
> this. This solution just strikes me as functional but
messy. Shouldn't
> instantiation code go inside the __init__?
>
> In the interim, I've thrown together some code. Is
there any reason
> not to do this:
>
> class Buffet(Tool):
> def __init__(self, customizable_arg):
> self.o = Create_Once(customizable_arg)
> self._point = "before_finalize"
> self.callable = do_something()
>
> def do_something(self): self.o.pull_trigger()
>
> class Root(object):
> def __init__(self):
> cherrypy.tools.buffet = Buffet('cheetah')
> cherrypy.config.update({'tools.buffet.on': True})
>
> quickstart(Root(), ...)
No reason at all. My hope was that Tools would allow this
style, too.
I would recommend two changes, though:
1. "self.callable = do_something()" -- I assume
you mean
"self.callable = self.do_something" ?
2. I'd write the Root class this way:
class Root(object):
_cp_config = {'tools.buffet.on': True}
def __init__(self):
cherrypy.tools.buffet = Buffet('cheetah')
...which turns on the tool in the application scope
instead of the site-wide global scope.
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|