Message from discussion
mounting test-controllers/getting root-controller instance?
Received: by 10.223.124.147 with SMTP id u19mr59406far.22.1246969356250;
Tue, 07 Jul 2009 05:22:36 -0700 (PDT)
Return-Path: <de...@web.de>
Received: from fmmailgate01.web.de (fmmailgate01.web.de [217.72.192.221])
by gmr-mx.google.com with ESMTP id 15si1067426bwz.6.2009.07.07.05.22.36;
Tue, 07 Jul 2009 05:22:36 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of de...@web.de designates 217.72.192.221 as permitted sender) client-ip=217.72.192.221;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of de...@web.de designates 217.72.192.221 as permitted sender) smtp.mail=de...@web.de
Received: from smtp08.web.de (fmsmtp08.dlan.cinetic.de [172.20.5.216])
by fmmailgate01.web.de (Postfix) with ESMTP id 20BAB108D8ED4;
Tue, 7 Jul 2009 14:22:36 +0200 (CEST)
Received: from [217.110.199.117] (helo=client8049.office.ableton.com)
by smtp08.web.de with asmtp (WEB.DE 4.110 #277)
id 1MO9gy-0007bj-00; Tue, 07 Jul 2009 14:22:36 +0200
From: "Diez B. Roggisch" <de...@web.de>
To: turbogears@googlegroups.com
Subject: Re: [TurboGears] Re: mounting test-controllers/getting root-controller instance?
Date: Tue, 7 Jul 2009 14:26:50 +0200
User-Agent: KMail/1.9.10
Cc: Jorge Vargas <jorge.var...@gmail.com>
References: <200905181255.50846.deets@web.de> <32822fe60905202322o37653d2bm90f5138b27bca2f8@mail.gmail.com>
In-Reply-To: <32822fe60905202322o37653d2bm90f5138b27bca2f8@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200907071426.50239.deets@web.de>
Sender: de...@web.de
X-Sender: de...@web.de
X-Provags-ID: V01U2FsdGVkX1/+pmKeRcL+izsoaRZdWLxuVOzLxivtZVMpkuTQ
phTCuJ8wlkdRQQJnx19hjkeqi+yworgrScrwJHg8My3CqHZ5eG
ns69lCelM=
On Thursday 21 May 2009 08:22:24 Jorge Vargas wrote:
> On Mon, May 18, 2009 at 6:55 AM, Diez B. Roggisch <de...@web.de> wrote:
> > 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.
>
> I don't know but I'll sure love to know if you find out.
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