Hi Graham, This looks like a workaround, but in the core I§m talking about exception when I also return "". I don't understand why I can't react to HEAD request, because exception will be raised in all cases (no care if I return something or not).
So the middleware is now best way, but it's hack and I not understand what exactly I should do here. Where is the point ? I'm voting for problem in pylons that should be corrected. I will look at it tonight, but if I need to write my own middleware to create normal searchable web then it seems me that pylons is hacky framework:( Thanks for help:) Petr 2008/9/17 Graham Dumpleton <[EMAIL PROTECTED]>: > > > > On Sep 17, 10:59 am, "Petr Kobalíček" <[EMAIL PROTECTED]> > wrote: >> Hi Wyatt, >> >> my biggest problem with this is that HEAD requests are used by bots, >> so the pylons pages are not indexable at all. This is big problem for >> me and I don't know how to solve this, because we are creating >> ecommerce software using pylons, sqlalchemy and qooxdoo for >> administration. I'm using pylons also for my web and here I found the >> problem:-( >> >> So, any ideas ;-) ? > > A workaround is to wrap your WSGI application in a middleware which > changes REQUEST_METHOD from HEAD to GET and which discards the > iterable returned from the application. The middleware should ensure > it still calls close() on the iterable properly though as per WSGI > specification requirements. > > Alternatively, you could make it work by hosting with Apache/mod_wsgi > and configuring Apache to enable Apache CONTENT_LENGTH output filter > for the application. This will work as when an Apache output filter is > configured, mod_wsgi will convert a HEAD request to a GET request > before passing it to the WSGI application. This is done so that actual > response content can be passed back to the Apache output filter, which > may want to adjust response headers based on the content. Apache will > discard any response content after any output filters are done with it > and will not send it back to the client. > > If this isn't done with Apache/mod_wsgi, the HEAD and GET requests may > not yield the same response headers. The CONTENT_LENGTH output filter > is chosen here purely because it is pretty benign, any Apache output > filter would have been enough to trigger this behaviour. > > Graham > >> Cheers >> - Petr >> >> 2008/9/17 Wyatt Baldwin <[EMAIL PROTECTED]>: >> >> >> >> > On Sep 16, 3:18 pm, "Petr Kobalíček" <[EMAIL PROTECTED]> wrote: >> >> So it's related to this >> >> ticked:http://pylonshq.com/project/pylonshq/ticket/507 >> >> >> I can't solve this bug myself, can anybody help me ? (I'm now using >> >> pylons from mercurial, but without success) >> >> >> Cheers >> >> - Petr >> >> >> 2008/9/16 Petr Kobalíček <[EMAIL PROTECTED]>: >> >> >> > So, >> >> >> > this is pylons bug ! >> >> >> > I tried to create plain application and to add hello controller >> >> > (that's in documentation). >> >> >> > The i tried this script: >> >> >> > import httplib >> >> >> > req = httplib.HTTPConnection("localhost:5000") >> >> > req.request("HEAD", "/hello/index") >> >> > res = req.getresponse() >> >> >> > print res.status, res.reason >> >> >> > Ad I got internal server error >> >> >> > Exception: No content returned by controller (Did you remember to >> >> > 'return' it?) in: 'HelloController' >> >> >> > So, what to do, is there any solution ? >> >> >> > Cheers >> >> > - Petr >> >> >> > 2008/9/16 Petr Kobalíček <[EMAIL PROTECTED]>: >> >> >> Hi devs, >> >> >> >> I have problem with HEAD requests that causes me Internal server error. >> >> >> >> The error exception: >> >> >> >> Exception happened during processing of request from ('127.0.0.1', >> >> >> 4948) >> >> >> Traceback (most recent call last): >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\paste-1.7.1-py2.5.egg\paste\ >> >> >> httpserver.py", line 1056, in process_request_in_thread >> >> >> self.finish_request(request, client_address) >> >> >> File "C:\PROGRA~1\Python25\lib\SocketServer.py", line 254, in >> >> >> finish_request >> >> >> self.RequestHandlerClass(request, client_address, self) >> >> >> File "C:\PROGRA~1\Python25\lib\SocketServer.py", line 521, in __init__ >> >> >> self.handle() >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\paste-1.7.1-py2.5.egg\paste\ >> >> >> httpserver.py", line 432, in handle >> >> >> BaseHTTPRequestHandler.handle(self) >> >> >> File "C:\PROGRA~1\Python25\lib\BaseHTTPServer.py", line 316, in handle >> >> >> self.handle_one_request() >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\paste-1.7.1-py2.5.egg\paste\ >> >> >> httpserver.py", line 427, in handle_one_request >> >> >> self.wsgi_execute() >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\paste-1.7.1-py2.5.egg\paste\ >> >> >> httpserver.py", line 287, in wsgi_execute >> >> >> self.wsgi_start_response) >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\paste-1.7.1-py2.5.egg\paste\ >> >> >> gzipper.py", line 35, in __call__ >> >> >> return self.application(environ, start_response) >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\paste-1.7.1-py2.5.egg\paste\ >> >> >> registry.py", line 350, in __call__ >> >> >> app_iter = self.application(environ, start_response) >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\Beaker-1.0.1-py2.5.egg\beake >> >> >> r\middleware.py", line 74, in __call__ >> >> >> return self.app(environ, start_response) >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\Beaker-1.0.1-py2.5.egg\beake >> >> >> r\middleware.py", line 147, in __call__ >> >> >> return self.wrap_app(environ, session_start_response) >> >> >> File "c:\program >> >> >> files\python25\lib\site-packages\Routes-1.9.2-py2.5.egg\route >> >> >> s\middleware.py", line 100, in __call__ >> >> >> response = self.app(environ, start_response) >> >> >> File "c:\my\python\pylons\pylons\wsgiapp.py", line 112, in __call__ >> >> >> "to 'return' it?) in: %r" % controller.__name__) >> >> >> Exception: No content returned by controller (Did you remember to >> >> >> 'return' it?) >> >> >> in: 'PagePublicController' >> >> >> >> Note, I read every document on internet related to pylons and HEAD, >> >> >> but I think problem is in pylons itself. I tried simple test like >> >> >> this: >> >> >> >> class PagePublicController(base.BaseController): >> >> >> def index_ROOT(self): >> >> >> return "" >> >> >> >> or >> >> >> >> class PagePublicController(base.BaseController): >> >> >> def index_ROOT(self): >> >> >> return [] >> >> >> >> and this produces internal server error too. >> >> >> >> here is some interesting stuff, but not solves my problem: >> >> >>http://pylonshq.com/pasties/922 >> >> >> >> So my question is, it's a bug or I'm doing something wrong ? >> >> >> >> Cheers >> >> >> - Petr >> >> > I just put a Pylons 0.9.7rc1 app into production and am see a bunch of >> > these errors, too. Mostly, they seem to be coming from user agents >> > other than browsers. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
