[Checkins] SVN: z3c.image/trunk/src/z3c/image/proc/ More tests and
whitespace cleanup.
Jürgen Kartnaller
juergen at kartnaller.at
Wed Jan 3 07:20:19 EST 2007
Log message for revision 71689:
More tests and whitespace cleanup.
Changed:
U z3c.image/trunk/src/z3c/image/proc/BROWSER.txt
U z3c.image/trunk/src/z3c/image/proc/browser.py
-=-
Modified: z3c.image/trunk/src/z3c/image/proc/BROWSER.txt
===================================================================
--- z3c.image/trunk/src/z3c/image/proc/BROWSER.txt 2007-01-03 09:52:28 UTC (rev 71688)
+++ z3c.image/trunk/src/z3c/image/proc/BROWSER.txt 2007-01-03 12:20:17 UTC (rev 71689)
@@ -24,7 +24,12 @@
>>> getImageInfo(browser.contents)
('image/jpeg', 103, 118)
+It must contain the last-modified time of the image.
+ >>> browser.headers.getheaders('Last-Modified')
+ ['... GMT']
+
+
If we do not specify parameters then the image is not processed.
>>> browser.open('http://localhost/flower.jpg/@@resized')
@@ -72,4 +77,13 @@
>>> getImageInfo(browser.contents)
('image/jpeg', 10, 10)
+
+We can use 'If-Modified-Since' in the request and get a 304 status.
+
+ >>> browser.addHeader('If-Modified-Since',browser.headers.getheader('Last-Modified'))
+ >>> browser.open('http://localhost/flower.jpg/@@resized')
+ Traceback (most recent call last):
+ ...
+ HTTPError: HTTP Error 304: Not Modified
+
TODO: more tests here
Modified: z3c.image/trunk/src/z3c/image/proc/browser.py
===================================================================
--- z3c.image/trunk/src/z3c/image/proc/browser.py 2007-01-03 09:52:28 UTC (rev 71688)
+++ z3c.image/trunk/src/z3c/image/proc/browser.py 2007-01-03 12:20:17 UTC (rev 71689)
@@ -42,7 +42,7 @@
class ImageProcessorView(BrowserView):
"""image processor"""
-
+
def __init__(self,context,request):
super(ImageProcessorView,self).__init__(context,request)
self.degrees =int(self.request.form.get('remote.adjust.rotate',0))
@@ -53,7 +53,7 @@
self.cropW = self.request.form.get('local.crop.w',None)
self.cropY = self.request.form.get('local.crop.y',None)
self.cropH = self.request.form.get('local.crop.h',None)
-
+
self.size = (self.width,self.height)
def _process(self):
@@ -64,10 +64,10 @@
pimg.rotate(self.degrees)
if self.width and self.height:
pimg.resize(self.size)
-
+
if self.cropX is not None and self.cropY is not None \
and self.cropW is not None and self.cropH is not None:
-
+
self.croparea = (int(self.cropX),
int(self.cropY),
int(self.cropX) + int(self.cropW),
@@ -105,8 +105,8 @@
self.request.response.setHeader('Last-Modified',
zope.datetime.rfc1123_date(lmt))
return self.processed()
-
-
+
+
class ResizedImageView(ImageProcessorView):
def __init__(self,context,request):
@@ -132,4 +132,3 @@
pimg.resize(new_size)
return pimg.process()
-
More information about the Checkins
mailing list