Re: Templating c Stacked Object
On Oct 9, 10:20 pm, Mike Orr [EMAIL PROTECTED] wrote: On Thu, Oct 9, 2008 at 7:27 PM, EricHolmberg [EMAIL PROTECTED] wrote: Are you sure? I've been putting 'c' assignments in BaseController.__call__ without problem, for things like the default page title and breadcrumbs. It works fine with debugging enabled, have you used it with the release version as well? I'm using it in production, yes. 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. Oh! Do I need to do a super(EmbeddedtracController, self).__call__(...) here? Not exactly, because you're not doing the superclass code and then something before or after it. You're doing something in the middle of the superclass code, and you can't call part of a parent method, break, execute your code, and then continue the parent method. But you can override ._dispatch_call(), which happens to be the part of code you want to change. I've heard things pro and con about super(). The consensus seems to be, if you know which superclass method to call, call it directly rather than using super(). -- Mike Orr [EMAIL PROTECTED] I have the distinct pleasure of taking over this project from Eirc, I'm VERY new to the system and would like a little more information, please. Where can I find the BaseController.__call__ ? I know this is a newbie question but it is part of this thread, take it easy on me. Thanks -Rick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Templating c Stacked Object
On Oct 14, 2:20 pm, RickMeyer [EMAIL PROTECTED] wrote: On Oct 9, 10:20 pm, Mike Orr [EMAIL PROTECTED] wrote: On Thu, Oct 9, 2008 at 7:27 PM, EricHolmberg [EMAIL PROTECTED] wrote: Are you sure? I've been putting 'c' assignments in BaseController.__call__ without problem, for things like the default page title and breadcrumbs. It works fine with debugging enabled, have you used it with the release version as well? I'm using it in production, yes. 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. Oh! Do I need to do a super(EmbeddedtracController, self).__call__(...) here? Not exactly, because you're not doing the superclass code and then something before or after it. You're doing something in the middle of the superclass code, and you can't call part of a parent method, break, execute your code, and then continue the parent method. But you can override ._dispatch_call(), which happens to be the part of code you want to change. I've heard things pro and con about super(). The consensus seems to be, if you know which superclass method to call, call it directly rather than using super(). -- Mike Orr [EMAIL PROTECTED] I have the distinct pleasure of taking over this project from Eirc, I'm VERY new to the system and would like a little more information, please. Where can I find the BaseController.__call__ ? I know this is a newbie question but it is part of this thread, take it easy on me. In a new project, it's in yourproject.lib.base. -wlb --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Templating c Stacked Object
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__). Thanks, I'll test that out and see what happens. -Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Templating c Stacked Object
Are you sure? I've been putting 'c' assignments in BaseController.__call__ without problem, for things like the default page title and breadcrumbs. It works fine with debugging enabled, have you used it with the release version as well? 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. Oh! Do I need to do a super(EmbeddedtracController, self).__call__(...) here? -Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Templating c Stacked Object
On Thu, Oct 9, 2008 at 7:27 PM, EricHolmberg [EMAIL PROTECTED] wrote: Are you sure? I've been putting 'c' assignments in BaseController.__call__ without problem, for things like the default page title and breadcrumbs. It works fine with debugging enabled, have you used it with the release version as well? I'm using it in production, yes. 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. Oh! Do I need to do a super(EmbeddedtracController, self).__call__(...) here? Not exactly, because you're not doing the superclass code and then something before or after it. You're doing something in the middle of the superclass code, and you can't call part of a parent method, break, execute your code, and then continue the parent method. But you can override ._dispatch_call(), which happens to be the part of code you want to change. I've heard things pro and con about super(). The consensus seems to be, if you know which superclass method to call, call it directly rather than using super(). -- 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 pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Templating c Stacked Object
So it looks like the templating engine isn't being setup, which makes sense since it normally wouldn't be needed. How can I setup the templating engine? Here's a normal dispatch to the root controller: 11:26:38,414 DEBUG [paste.httpserver.ThreadPool] Added task (0 tasks queued) 11:26:38,414 DEBUG [routes.middleware] Matched GET / 11:26:38,414 DEBUG [routes.middleware] Route path: '/', defaults: {'action': u'index', 'controller': u'root'} 11:26:38,414 DEBUG [routes.middleware] Match dict: {'action': u'index', 'controller': u'root'} 11:26:38,414 DEBUG [pylons.wsgiapp] Setting up Pylons stacked object globals 11:26:38,414 DEBUG [pylons.wsgiapp] Resolved URL to controller: u'root' 11:26:38,414 DEBUG [pylons.wsgiapp] Controller appears to be a class, instantiating 11:26:38,414 DEBUG [pylons.wsgiapp] Calling controller class with WSGI interface 11:26:38,414 DEBUG [pylons.controllers.core] Looking for u'index' method to handle the request 11:26:38,414 DEBUG [pylons.controllers.core] Calling 'index' method with keyword args: **{} 11:26:38,414 DEBUG [pylons.templating] Render called with ['genshi'] args and {} keyword args 11:26:38,414 DEBUG [pylons.templating] Updated render namespace with pylons vars: {'c': pylons.util.AttribSafeContextOb j at 0x24a3f70 bHasAuthCookie=False, bSessionValid=False, links=[{'url': 'searchBasic/0/1/test', 'name': 'searchBasic (J SON)...ge'}], 'render': function render at 0x0166AAF0, 'g': casehistory.lib.app_globals.Globals object at 0x01B24690 , 'h': module 'casehistory.lib.helpers' from 'C:\Projects\CaseHistory\CaseHistory-Pylons\casehistory\lib\helpers.pyc' , 'request': paste.wsgiwrappers.WSGIRequest object at 0x24a3bd0 method='GET', scheme='http', host='localhost:5000', script_name='', path_info='/', languages=['en-us'], charset='utf-8', errors='replace', And here is the dispatch to the EmbeddedtracController: 11:34:02,937 DEBUG [paste.httpserver.ThreadPool] Added task (0 tasks queued) 11:34:02,937 DEBUG [routes.middleware] Matched GET /ArrowEscWiki/ chrome/common/trac_banner.png 11:34:02,937 DEBUG [routes.middleware] Route path: '/ArrowEscWiki/ *path_info', defaults: {'action': u'index', 'controlle r': u'EmbeddedTrac'} 11:34:02,937 DEBUG [routes.middleware] Match dict: {'action': u'index', 'controller': u'EmbeddedTrac', 'path_info': 'chr ome/common/trac_banner.png'} 11:34:02,937 DEBUG [pylons.wsgiapp] Setting up Pylons stacked object globals 11:34:02,937 DEBUG [pylons.wsgiapp] Resolved URL to controller: u'EmbeddedTrac' 11:34:02,937 DEBUG [pylons.wsgiapp] Controller appears to be a class, instantiating 11:34:02,937 DEBUG [pylons.wsgiapp] Calling controller class with WSGI interface Any ideas are appreciated. -Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Templating c Stacked Object
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__). which results in the following error message: c.input = strHtml File 'c:\\python25\\lib\\site-packages\\paste-1.7.1-py2.5.egg\\paste\ \registry.py', line 140 in __setattr__ setattr(self._current_obj(), attr, value) File 'c:\\python25\\lib\\site-packages\\paste-1.7.1-py2.5.egg\\paste\ \registry.py', line 194 in _current_obj 'thread' % self.name__) TypeError: No object (name: C) has been registered for this thread -- Philip Jenvey --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Templating c Stacked Object
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 pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Templating c Stacked Object
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) which results in the following error message: c.input = strHtml File 'c:\\python25\\lib\\site-packages\\paste-1.7.1-py2.5.egg\\paste\ \registry.py', line 140 in __setattr__ setattr(self._current_obj(), attr, value) File 'c:\\python25\\lib\\site-packages\\paste-1.7.1-py2.5.egg\\paste\ \registry.py', line 194 in _current_obj 'thread' % self.name__) TypeError: No object (name: C) has been registered for this thread Thanks, Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---