[Grok-dev] NotFound: Object: <zope.site.folder.Folder object at 0x#######>, name: u'favicon.ico'
Jan-Jaap Driessen
jdriessen at thehealthagency.com
Mon Jan 10 03:31:54 EST 2011
On 9 January 2011 22:45, Hector Blanco <white.lists at gmail.com> wrote:
> Thank you for the follow-up, guys!
>
> It is finally working. I decided to go with the resource_string...
>
> ---------------------------------------------
> from pkg_resources import resource_string
> # [ . . . ]
> class Favicon(grok.View):
> grok.context(Interface)
> grok.name('favicon.ico')
>
> def render(self):
> return resource_string(__name__, "static/img/icons/favicon.ico")
> ---------------------------------------------
>
> Now I have realized that the favicon looks horrible and that I have to
> re-design it but hey... that wasn't the point here :-D
>
> Thank you so much!
>
>
> 2010/12/31 Jan-Jaap Driessen <jdriessen at thehealthagency.com>:
>> On 31 December 2010 11:39, Vincent Fretin <vincent.fretin at gmail.com> wrote:
>>> 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()
>>
>> Or use resource_string(...) instead of resource_stream(...).read()
>>
>>> Happy new year!
>>>
>>> Vincent
>>>
>>
>> --
>> Jan-Jaap Driessen
>>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>
In the hopefully-soon-to-be-released-grok, which includes fanstatic,
adding a favicon will be much easier. Have a look at the trunk of
grokui.base:
http://zope3.pov.lt/trac/changeset/119341
The link to the favicon is included in the layout and the favicon is
treated like any other resource, served by the fanstatic publisher.
--
Jan-Jaap Driessen
More information about the Grok-dev
mailing list