[Grok-dev] Enable gzip/http compression in Grok/Zope site

Hector Blanco white.lists at gmail.com
Mon Aug 2 11:52:31 EDT 2010


Hello everyone...

I would like to know how I can send compressed data from my server
(using Grok/Zope3).

I am using TAL templates to generate the HTML. For instance:

(template in file test.pt)
-----------------------------------
<html>
	<head>
		<title>TEST</title>
		<link rel="stylesheet" type="text/css" tal:attributes="href
static/css/forms.css" />
		<link rel="stylesheet" type="text/css" tal:attributes="href
static/css/layout.css" />
		<link rel="stylesheet" type="text/css" tal:attributes="href
static/css/nav-horizontal.css" />
		<link rel="stylesheet" type="text/css" tal:attributes="href
static/css/plugins.css" />
		<link rel="stylesheet" type="text/css" tal:attributes="href
static/css/tools.css" />
		<link rel="stylesheet" type="text/css" tal:attributes="href
static/css/typo.css" />
		<link rel="stylesheet" type="text/css" tal:attributes="href
static/css/colorpicker.css" />

		<script type="text/javascript" tal:attributes="src
static/js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" tal:attributes="src
static/zjs/myutil.js"></script>
		<script type="text/javascript" tal:attributes="src
static/zjs/myincludes.js"></script>
-----------------------------------

When the user goes to: http://127.0.0.1:8080/my-application/test ,
this is handled in app.py by:

class Test(grok.View):
	grok.context(Grokserver)
	grok.require('viewsite')

I would like to know if I can easily send some (or all) of the
information compressed in gzip. The information generated by the
template is huge, and any compression would be helpful.

If I could get to send the .js files compressed with gzip, it would be
a great improvement (or even better: if I can send the "test" page in
gzip)

I've been googling a lot and I haven't seen any good way to send
compressed data.

Thank you in advance!


More information about the Grok-dev mailing list