ImageKicker.py - some problems solved?

Malte Cornils <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Hello,

I've been using ImageKicker.py and some weblog-add modifications to enable 
image upload via WWW.

I've found ImageKicker.py to be malfunctioning; the attached patch solves 
those problems for me. Maybe you could have a look at it. BTW, why is the 
renderer.addHeaders() stuff not working for me? I'm using pyblosxom 1.2.x on 
Debian sarge.

Bye,
-Malte

PS: Please Cc: me as I'm not subscribed currently.
imagekicker-patch-versus-0.2.diff (text/x-diff, 1.1 KB)
--- imagekicker.py	2004-04-28 00:40:09.000000000 +0200
+++ public_html/cgi-bin/blog-plugins/imagekicker.py	2006-02-15 21:52:46.000000000 +0100
@@ -35,13 +35,13 @@
 	config = request.getConfiguration()
 	goodtime = 1
 	
-	if config.has_key("imagedata"):
+	if not config.has_key("imagedata"):
 	    print "Required variable imagedata not set"
 	    goodtime = 0
 		
 	return goodtime
 
-def cb_start(args):
+def cb_pathinfo(args):
 	import string
 	request = args["request"]
 
@@ -61,6 +61,10 @@
 		#get various information
 		pos = string.find(filename, ".")
 		type = filename[pos + 1:]
+		
+		if type == "jpg":
+			type = 'jpeg'
+			
 		length = len(file)
 
 		resp_str = 'Content-Type: image/' + type + '\n' + \
@@ -70,6 +74,13 @@
 		sys.stdout.write(resp_str)
 		sys.stdout.flush()
 		sys.stdout.write(file)		
+
+		# alternative version (doesn't work: why?)
+		#renderer.addHeader('Content-Type', ('image/' + type))
+		#renderer.addHeader('Content-Length', str(length))
+		#renderer.needsContentType(0)
+		#renderer.showHeaders()
+		#renderer.write(file)
 		
 		# Tell renderer that it is done
 		renderer.rendered = 1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.