mounting test-controllers/getting root-controller instance?

11 views
Skip to first unread message

Diez B. Roggisch

unread,
May 18, 2009, 6:55:50 AM5/18/09
to TurboGears
Hi,

is there a way to obtain a reference to the root-controller-object so that I
can attach a hierarchy of test-only controllers to it?

This is TG2 of course.

Diez

Jorge Vargas

unread,
May 21, 2009, 2:22:24 AM5/21/09
to turbo...@googlegroups.com
I don't know but I'll sure love to know if you find out.

> Diez
>
> >
>

Diez B. Roggisch

unread,
Jul 7, 2009, 8:26:50 AM7/7/09
to turbo...@googlegroups.com, Jorge Vargas

I finally did.


Assuming the paster-stuff is bootstrapped through code like


here_dir = os.path.dirname(os.path.abspath(ableton.__file__))
conf_dir = os.path.dirname(here_dir)
wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)

you then can do it simply like this (inside a function/method!!)

import myproject.controllers.root as root
root.RootController.mountpoint = TestController()


Then you can access the controller through the usual

self.app.get("/mountpoint/action")

Of course mounting of whole controller hierarchies is perfectly fine.

So I create a function in our base-test-class that allows to register a passed
controller for a given mountpoint. Voila, greatness ensues.

Diez

Reply all
Reply to author
Forward
0 new messages