This problem is not so much TurboGears as it is Python. That's not to say
we can't (or won't) help, don't worry. Just remember that this applies to
all the work you could do in Python.

The variable you have listed below, "test", is actually a variable within
the module. I'm pretty sure the module is example.controllers.root

This means that, in order to access the variable elsewhere, you have to
import the module, and then you can access the variable. Now, in your case,
you'd be trying to import the root controller into subcontrollers, and that
sort of practice is normally frowned upon. You might get it to work
reliably, but people won't like seeing code that imports a module that
imports the original module.

I would move that variable into yet another module, possibly under your lib
module. From there, in each module, you can then "from example.lib.module
import test" in all your controllers, and then "flash(test)" will work as
desired.

On Tue, Jul 17, 2012 at 3:59 AM, abc_coder <[email protected]>wrote:

> Hi all
>
> It's may be very easy but I don't know how can I pass argument/variable
> from controller to subcontroler?
>
> Some example code:
> ------------------
> from example.controllers.one import OneController
> from example.controllers.two import TwoController
>
> test = u'Do some test!'
>
> class TestController(BaseController):
>     one = OneController()
>     two = TwoController()
>
>     @expose('example.templates.index')
>     def index(self):
>         flash(test)
>         return dict(page='index')
> --------------------------
> I want to pass this variable/argument "test" to subcotnrollers.
> When I do in subcontroller flash(test) it should flash: 'Do some test!'
> like it work in main controller.
>
> How can I do this?
> please help
>
> regards
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/p6n3LTvQLcsJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.
>



-- 
Michael J. Pedersen
My Online Resume: http://www.icelus.org/ -- Google+ http://plus.ly/pedersen
Google Talk: [email protected] -- Twitter: pedersentg

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to