[Grok-dev] checked in: megrok.resourcelibrary

Martijn Faassen faassen at startifact.com
Wed Aug 6 12:34:46 EDT 2008

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):

Your resources will then be published under:


The library allows you to declare you actually need some resources in 
the head section of a HTML page whenever you use them:

class MyResources(megrok.resourcelibrary.ResourceLibrary):

This will make 'foo.js' and 'bar.css' whenever you use this resource 
library in a page. You can declare this requirement like this in a ZPT:

   <tal:block replace="resource_library: myresources" />

or like this in Python code that is used to display the page (such as in 
a widget that needs some javascript to be included):


There are some other features, some of which are undertested, such as 
putting resources in a particular layer. There's also a feature that I 
did try to test but doesn't work yet, protecting resources behind 

People are welcome to give this a spin, add more code/tests and write 
tutorials. :)



More information about the Grok-dev mailing list