On Wed, Mar 17, 2010 at 8:10 PM, Mike Orr <[email protected]> wrote:
> On Wed, Mar 17, 2010 at 11:24 AM, Wyatt Baldwin
> <[email protected]> wrote:
>> On Mar 17, 10:27 am, Eric Lemoine <[email protected]> wrote:
>>> Hello
>>>
>>> From a controller can I get a reference to the app (i.e. what's
>>> returned by middleware.make_app)?
>>
>> Right before `return app`, you could do `app_globals.app = app` (in
>> fact, I think the docs for 1.0 say to do `config.app = app` anyway).
>
> I think Pylons did that as a kludge because it needed access to the
> app. (The config initialization was reorganized to make it friendlier
> to nested applications, and apparently that severed the direct link
> between the app and some part of Pylons.) I'm not sure if I like
> setting ``config.app`` that way, but I'm not sure it's necessarily bad
> either. ``config`` is where I'd look for the app if I were trying to
> find it.
>
>> However... there's a potential issue here in that if you define
>> filters or a pipeline in your paste config, the app returned by
>> make_app will be wrapped with those other apps, so the one you saved
>> won't be the "root" app, which may or may not matter for your
>> scenario.
>>
>> Having said that, it seems to me that there *must* be another way to
>> get at the "root" app, but I didn't dig very hard. I also ended up
>> rewriting the code I had that utilized `app`. I'm not sure, but it
>> might be a bad practice to use/need `app` in that way.
>
> Not sure about this. Paste.composite is outside the realm of what the
> application code should be caring about?
In my case I think I'd like the root app. Here's what I am up to:
create a controller responsible for live-testing the application. So I
was thinking about something like that for this test controller:
class CheckerController(BaseController):
def index(self):
# creating test app
app = config["map"] # ???
app = TestApp(map)
# test entry controller
response = app.get(url(controller='entry', action='index'))
assert "app.js" in response
# test print controller
response = app.get(url(controller='printer', action='info',
var='printCapabilities'))
assert 'printCapabilities' in response
assert '"scales":[' in response
return "green"
Maybe I'm not taking a good direction, and I'd rather use urllib or
something and do actual HTTP requests to the application.
What do you think?
Thanks,
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : [email protected]
http://www.camptocamp.com
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en.