I have dynamic css working, and I thought I'd post it here for the
record.
The CSS itself goes in a view, css/styles.css in this trivial example:
=======
body { font-family: Verdana, sans-serif; }
div.beautify td {
padding-top: 0;
}
=======
It's served up by controller css.py. The only piece that's strictly
necessary is the text/css Content-Type. However, dynamic content is
served up with a cookie (unnecessary overhead for a css file) and with
no caching, which is also inappropriate for css. So I clean up the
headers, and give the file a life of an hour (somewhat arbitrarily).
Ideally this would happen in wsgibase(), perhaps keyed off the .css
extension.
=======
import time
from gluon.storage import Storage
def __cssheaders():
response.cookies = Storage()
response.headers['Content-Type']='text/css'
response.headers['Cache-Control'] = 'max-age=3600, must-revalidate'
if 'Last-Modified' in response.headers: del
response.headers['Last-Modified']
if 'Expires' in response.headers: del response.headers['Expires']
if 'Pragma' in response.headers: del response.headers['Pragma']
return dict()
def styles():
return __cssheaders()
=======
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---