derks/cement — Issue #68: Portland: self.log in stacked controller not working
Author: matysek
Created: 2011-10-25 19:55:57+00:00
State: open

I was trying the following code example, logging in the command2() function is not working. I get this error:

```
Traceback (most recent call last):
File "controller.py", line 39, in
app.run()
File "/home/martin/tmp/helloworld_app/env/lib/python2.7/site-packages/cement2-1.9.1-py2.7.egg/cement2/core/foundation.py", line 94, in run
self.controller.dispatch()
File "/home/martin/tmp/helloworld_app/env/lib/python2.7/site-packages/cement2-1.9.1-py2.7.egg/cement2/core/controller.py", line 234, in dispatch
getattr(controller, func['label'])()
File "controller.py", line 30, in command2
self.log.info('Inside controller2.command2 function.')
AttributeError: 'NoneType' object has no attribute 'info'
```

How to reproduce: run the following code example like:

```
python code_example.py command2
```

code example:

```
from cement2.core import backend, foundation, controller, handler

# create an application
app = foundation.lay_cement('example')

# define an application base controller
class MyAppBaseController(controller.CementBaseController):
class meta:
interface = controller.IController
label = 'base'
description = "My Application does amazing things!"
defaults = dict()
arguments = []

class Controller2(controller.CementBaseController):
class meta:
interface = controller.IController
label = 'controller2'
stacked_on = 'base'
description = 'This is the description for controller2.'
defaults = dict()

arguments = [
(['--foo2'], dict(action='store', help='the notorious foo option')),
]

@controller.expose(hide=False, help='A command from a stacked controller')
def command2(self):
self.log.info('Inside controller2.command2 function.')

handler.register(MyAppBaseController)
handler.register(Controller2)

# setup the application
app.setup()

# run the application
app.run()
```