On Wed, Oct 8, 2008 at 4:52 PM, Philip Jenvey <[EMAIL PROTECTED]> wrote:
>
>
> On Oct 7, 2008, at 5:01 PM, EricHolmberg wrote:
>
>>
>> How can I create the global c variable that is used in the templates
>> if I'm in an WSGI app and not in a controller response method?
>>
>> With the WSGI dispatch, I need to rewrite some of the output using
>> Genshi, so I have the following code:
>>
>> class EmbeddedtracController(BaseController):
>>
>> def __init__(self):
>> # set application to the trac WSGI dispatch_request function
>> self.app = dispatch_request
>> self.trac_env_path = config['trac_env_path']
>>
>> def __call__(self, environ, start_response):
>> """Dispatches request to trac."""
>> ...
>> self.rewriteLoginPage(environ, strHtml)
>> ...
>> def _rewriteLoginPage(self, environ, strHtml):
>> """Handles the 403 Forbidden response."""
>>
>> # Set variables for Genshi
>> c.input = strHtml
>> ...
>> return render("genshi", "TracLogin")
>
>
> Probably the best place for calling _rewriteLoginPage would in a
> __before__ method. __call__ is the main entry point into Controllers,
> and unfortunately by that point variables like c aren't setup yet.
> Whereas they would be in __before__ (and __after__).
Are you sure? I've been putting 'c' assignments in
BaseController.__call__ without problem, for things like the default
page title and breadcrumbs.
The problem here seems to be that BaseController.__call__ is not
called at all. If .__before__ doesn't work, I think you'll have to
override WSGIController._dispatch_call() (the superclass of
BaseController, defined in pylons.controllers.core), which is what
does the normal action lookup and calling.
--
Mike Orr <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---