[Grok-dev] Re: checked in: megrok.resourcelibrary
Wichert Akkerman
wichert at wiggy.net
Thu Aug 7 02:34:11 EDT 2008
Previously Martijn Faassen wrote:
> Wichert Akkerman wrote:
> >Previously Martijn Faassen wrote:
> >>Hi there,
> >>
> >>I just checked in a package called megrok.resourcelibrary. It wraps
> >>zc.resourcelibrary and all the real functionality is in that library,
> >>this just grokifies it. In essence megrok.resourcelibrary lets you set
> >>up your own new 'static' directories.
> >>
> >>What you can do with this is the following:
> >>
> >>import megrok.resourcelibrary
> >>
> >>class MyResources(megrok.resourcelibrary.ResourceLibrary):
> >> megrok.resourcelibrary.directory('some_directory')
> >
> >Isn't this something that could be setup using config.ini or a wsgi
> >middleware layer? It feels like using python to configure a deployment.
>
> I don't think so. A package may want to ship with resources. Imagine a
> widget that needs a javascript file present. Or a package that
> implements a layout that needs some images. Or a package that has some
> kss files that expect to work together with Python code.
>
> These resources are often intimately related with the code in the Python
> package. It's also nice to be able to construct a virtual-host aware URL
> for them.
Pylons does the same thing, and may others probably as well. We are
seeing the exact same limitations everywhere: serving these static
resources through the application server is always a bottleneck when you
scale a site. In Zope much more so than elsewhere since Zope uses a very
low number of threads.
There are basically two things that you need: a way to construct a URL
to a resource and a way to conveniently serve those resources.
resourcelibrary does both, but I am advocating that it should be
possible to split them up. I want to be able to say 'my resources are at
http://static.mysite.com' and use apache to serve them without having
to rewrite all my templates.
Wichert.
--
Wichert Akkerman <wichert at wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
More information about the Grok-dev
mailing list