[Grok-dev] NotFound: Object: <zope.site.folder.Folder object at 0x#######>, name: u'favicon.ico'

Vincent Fretin vincent.fretin at gmail.com
Fri Dec 31 05:39:53 EST 2010


Hi,

With the code given by Jan-Jaap, if you try to access to favicon.ico, you
get:
*TypeError: The result should be None, a string, or adaptable to IResult.
*
Simply add read() and it works fine. I can see the favicon in the url bar.
return resource_stream('dolmenexample', 'favicon.ico').read()

Happy new year!

Vincent


On Mon, Dec 13, 2010 at 8:38 PM, Hector Blanco <white.lists at gmail.com>wrote:

> It works... well I still don't know if it's really serving the icon or
> not, but at least it doesn't complain :)
>
> 2010/12/11 Jan-Jaap Driessen <jdriessen at thehealthagency.com>:
> > On 10 December 2010 22:47, Hector Blanco <white.lists at gmail.com> wrote:
> >> Hello everyone!
> >>
> >> I have a problem that is not too serious but that has been bothering
> >> me a little...
> >>
> >> When I request a page from my Grok server (in debug mode), I get an
> exception
> >> Debug at: http://127.0.0.1:8080/_debug/view/1292017221
> >>
> >> And it's because it doesn't find the favicon.ico:
> >>
> >> URL: http://127.0.0.1:8080/favicon.ico
> >> Module paste.evalexception.middleware:306 in respond
> >> [ . . . stuff, stuff, stuff . . .]
> >> NotFound: Object: <zope.site.folder.Folder object at 0x976476c>, name:
> >> u'favicon.ico'
> >>
> >> But sometimes, when I'm developing something new, it scares the s**t
> >> out of me (I think I've done a bad mistake). I wouldn't mind providing
> >> a sample (even empty) icon so it would find it and it won't complain
> >> anymore, but I don't know where to place it.
> >>
> >> Thank you in advance!
> >
> > Hi Hector,
> >
> > You can register a response for favicon.ico like this (pseudo-code, not
> tested):
> >
> > '''
> > from pkg_resources import resource_stream
> >
> > from zope.interface import Interface
> > import grok
> >
> > class Favicon(grok.View):
> >    grok.context(Interface)
> >    grok.name('favicon.ico')
> >
> >    def render(self):
> >        self.request.response.setHeader('Content-Type',
> > 'image/vnd.microsoft.icon')
> >        return resource_stream('mypackage', 'path/to/favicon.ico')
> > '''
> >
> > HTH,
> >
> > --
> > Jan-Jaap Driessen
> >
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20101231/44b02fd6/attachment.html 


More information about the Grok-dev mailing list