Newbie question on running external method
Hello, I'm still working on my Zope site, and I have another problem again. I have a MySQL table called Photos and with column names: filename, foldername, PhotoID(primary key). ReadPhotoID is the ZSQL method by passing folder data and get back filename, PhotoID. photorename is the external method to pass the foldername, filename and PhotoID data, and rename the file name from "filename" to "PhotoID", eg. from "abcd.jpg" to "123.jpg". photorename code is : import os def photorename(folder, filename, photoID): os.renames("/Finish/"+folder+"/"+filename,"/Finish/"+folder+"/"+photoID+".jpg") So, I use the following code: <dtml-in "ReadPhotoID(foname=REQUEST.get('folder'))"> <dtml-var "photorename(REQUEST.get('folder'),filename, PhotoID)"> </dtml-in> It shows a site error with "_mysql_exceptions.NotSupportedError". However, it runs ok when I just show the data: <dtml-in "ReadPhotoID(foname=REQUEST.get('folder'))"> <dtml-var filename> <dtml-var PhotoID> </dtml-in> or put the data manually in the external method: <dtml-var "photorename(REQUEST.get('folder'), 'abcd.jpg', '123')"> Did I miss something? I worked on this problem 2 days and still cannot find out which part is wrong. Please tell me anything wrong if you found it. Thanks in advance. Leo
Hi Leo, please don't post HTML to the list. Since the exception is a mysql exception, it might help to see the query you are actually attempting. I'm guessing that maybe there is some other difference between the method that works, and the one that fails, that affects the query you are generating with your ReadPhotoID ZSQL Method. You might try replacing your loop with: <dtml-var "ReadPhotoID(foname=REQUEST.get('folder'), src__=1)"> this should display the query, and possibly some clues. good luck! -steve On Friday, May 17, 2002, at 01:27 PM, Leo wrote:
Hello, I'm still working on my Zope site, and I have another problem again. I have a MySQL table called Photos and with column names: filename, foldername, PhotoID(primary key). ReadPhotoID is the ZSQL method by passing folder data and get back filename, PhotoID. photorename is the external method to pass the foldername, filename and PhotoID data, and rename the file name from "filename" to "PhotoID", eg. from "abcd.jpg" to "123.jpg". photorename code is : import os def photorename(folder, filename, photoID): os.renames("/Finish/"+folder+"/"+filename,"/Finish/"+folder+"/"+photoID+".jpg" ) So, I use the following code: <dtml-in "ReadPhotoID(foname=REQUEST.get('folder'))"> <dtml-var "photorename(REQUEST.get('folder'),filename, PhotoID)"> </dtml-in> It shows a site error with "_mysql_exceptions.NotSupportedError". However, it runs ok when I just show the data: <dtml-in "ReadPhotoID(foname=REQUEST.get('folder'))"> <dtml-var filename> <dtml-var PhotoID> </dtml-in> or put the data manually in the external method: <dtml-var "photorename(REQUEST.get('folder'), 'abcd.jpg', '123')"> Did I miss something? I worked on this problem 2 days and still cannot find out which part is wrong. Please tell me anything wrong if you found it. Thanks in advance. Leo
On Fri, 2002-05-17 at 14:27, Leo wrote:
It shows a site error with "_mysql_exceptions.NotSupportedError".
That almost always only occurs when you have transactions enabled on non-transaction safe tables and a rollback is issued for some reason, usually due to some other exception being raised. If you started your ZMySQLDA connection string with +, remove it; otherwise start it with - to disable transactions; or change your MySQL tables to use a transaction-safe table type (InnoDB or BDB). Note to Zopemeisters: Would it be feasible to change Zope's top level exception handling so that if another exception is raised during the transaction abort, the original exception error page is not lost, perhaps including both exception backtraces? -- Andy Dustman PGP: 0x930B8AB6 @ .net http://dustman.net/andy "Cognito, ergo sum." -- Rene Descartes "I yam what I yam and that's all that I yam." -- Popeye
participants (3)
-
Andy Dustman -
Leo -
Steve Spicklemire