[Zope] FileUpload, MySQL, Zope ZSQL problem

Michael Joseph michael at jamwarehouse.com
Thu Jan 22 03:15:53 EST 2004


You're right- you're not escaping the binary data when doing your MySQL
insert.  You need to research escaping parameters in ZSQL methods- perhaps
try using <dtml-sqlvar type=string ..> ?

> -----Original Message-----
> From: Quince Gibson [mailto:quince at us3media.com] 
> Sent: Wednesday, January 21, 2004 6:21 PM
> To: Michael Joseph
> Cc: zope at zope.org
> Subject: Re: [Zope] FileUpload, MySQL, Zope ZSQL problem
> 
> Thanks for the quick response.  I'm not sure exactly how to 
> use read() but I did manage to find some sort of work 
> around.  But now I have another problem.  I created a python 
> script "create_file" with the following:
> #parameters: file_name
> context.manage_addProduct['OFSP'].manage_addFile(id="uploadedf
> ile", title="", file=file_name)
> doc=getattr(context, "uploadedfile")
> context.manage_delObjects('uploadedfile') #would defeat the 
> purpose if I didn't
> return doc.data # tested it and it returns the file
> 
> I then called it in my ZSQL Method using:
> <dtml-var expr=create_file(picture1)>
> 
> Also tried it in quotes:
> '<dtml-var expr=create_file(picture1)>'
> 
> Although the script works and returns the file's data, I get 
> the following error (changes with the file):
> Error Type: ProgrammingError
> Error Value: (1064, "You have an error in your SQL syntax. 
> Check the manual that corresponds to your MySQL server 
> version for the right syntax to use near ''GIF89a\x0f' at line 38")
> 
> The data type I'm using in MySQL for that field is "blob."
> 
> Interestingly enough, if I'm trying to upload a text file, 
> the whole setup works.
> 
> Any Suggestions?  Something tells me I should be looking at 
> MySQL and not Zope (ie. html quoting equivalent for binary 
> data)
> 
> Thanks in advance for your help.




More information about the Zope mailing list