[Grok-dev] Conditional linking to static images
luciano at ramalho.org
Wed Jul 4 13:50:34 EDT 2007
On 7/3/07, Darryl Cousins <darryl at darrylcousins.net.nz> wrote:
> Would this be what you need?:
> os.path.join(os.path.dirname(__file__), 'static')
Thanks, Darryl. Leo Rochael was here last night and we discovered a
very elegant and Zope3-ish solution:
def coverUrl(self, name):
cover_name = 'covers/medium/'+name+'.jpg'
Initially we were confused by the API docs for DirectoryResource and
FileResource, but that is because they are very Pythonic and a lot of
their functionality is in their dictionary-like interface. And the
FileResource is called to render it's URL, which is also obvious after
we hit upon it (getting the URL is really the most common thing to do
with a static file).
I'm really thrilled to discover how much more pythonic Zope 3 compared
to Zope 2.
More information about the Grok-dev