[Grok-dev] image files in a folder
sebastian at urbantalk.se
Mon Jul 19 12:09:07 EDT 2010
minor typo, the tal stuff is missing an attribute specifier "src":
<img src="" tal:attributes="src python: view.url('someimage')" />
17 jul 2010 kl. 17.43 skrev Jan-Wijbrand Kolman:
> On 7/13/10 17:54 PM, Uwe Hentzschel wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>> i have many image files in a folder like '/Users/uhe/images'. I have to
>> manipulate the files with PIL. How can a pagetemplate show images from
>> a folder (not the "static" folder.). It is not nessery to save the
>> manipulated images.
> One way to do it would be something like this:
> class SomeImage(grok.View):
> def render(self):
> # This will return an file object as the response content.
> # Zope knows how to deal with returning file contents.
> return open('path/to/image.png')
> In you pagetemplate you can then do something like:
> <img src="" tal:attributes="python: view.url('someimage')" />
> But you might be better of by registering a DirectoryResource for the
> directory holding your images.
> regards, jw
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev