[Zope-CMF] "statify" css

robert robert at redcor.ch
Sat Jan 22 15:44:27 EST 2005


Dieter thank you very much for your answer,

>>I created a tool cssGrabber that writes all css files that are used in a 
>>CMF/Plone site and writes them into a skin directoriy (in the FS) and 
>>adds a .metadata file with cacheing information.
>>EG for a standard plone site if creates files like the following:
>>ploneColumns.css.dtml
>>ploneColumns.css.dtml.metadata
>>...
>>
>>agin, does that make sense??
>>    
>>
>
>As always with caches (either the own you implemented yourself
>or a standard cache) you must be aware of cache inconsistencies.
>
>When you change the configuration (such that e.g. "ploneColumns.css"
>would get created differently) or the object even adapts
>automatically to the context (to current browser, user), then
>your cached version would become inconsistent.
>
>  
>
What I did, when writing my css files was reading them with code similar 
to the following  
    callURL   = 
'http://intranet.fh-aargau.ch:8380/intranet/intranetFHA1.5/XXX'
    target = "/home/zope/Products/Projects/FHA2Data/skins/fha/aaa/"
    f = urllib.urlopen(callURL)
    data = f.read()
    f.close()
    cssmatcher = re.compile(r'http.+\.css')
    result = cssmatcher.findall(data)
    if result:
        for url in result:
            f = urllib.urlopen(url)
            data = f.read()
            f.close()
            fname = url.split('/')[-1]
            if len(data):
                # write css
                p = "%s/%s.dtml" % (target, fname)
                f = open(p, 'w')
                f.write(data)
                f.close()
                print "\n%s %s" % (len(data), p)
                # write its metadata
                p = "%s/%s.dtml.metadata" % (target, fname)
                f = open(p, 'w')
                f.write(metadata % fname)
                f.close()
                print "\n%s %s" % (len(data), p)
.
I assume that the by reading a css  through its url, I get a "rendered" 
version that is safe to cache.
I then write them to the FS with a metadata file with content similar to 
the following.

[default]
title = plone.css
cache = HTTPCache

If my assumption is correct, I wonder, why something like this is not 
part of CMF/Plone since the css files sum up to 97k. Which is probably 
more than the rest the page.

If I am wrong, I would be glad if somebody would point to the flaws in 
my reasoning

Robert


More information about the Zope-CMF mailing list