Can Zope extract an image (BLOB) from an RDB ?
I've got 8000 photos (jpeg format) stored in an Oracle database. The table that contains the photos has these columns which are of interest : PICTURE LONG RAW PICTURE_LENGTH NOT NULL NUMBER(14) My goals in order of progression are : 1. Extract the image from the database using ZSQL methods 2. Serve that image up directly to the web browser 3. Save the image to the filesystem or, even better, create a Zope Image Object Unfortunately, I'm stuck at step 1. Doing a request on the database with ZSQL methods is returning : Error, oci.error: (911, 'ORA-00911: invalid character\012') Is there any way for Zope to handle this or is this going to involve python-DCOracle scripts instead and then uploading into Zope ? Thank you very much in advance, chas
I've never done it, and it's not well-documented (ie. I have no idea if it really works), but I believe the Oracle DA can retrieve BLOBS... Here the CHANGES.txt file from ZOracleDA: Z Oracle DA Releases 2.2.0 Added a small feature that allows you to access LOBs in the Oracle database. To do this, you must have your maximum number of results set to '1'. Otherwise, it won't work. In addition, several bugs were resolved. 2.1.0 Based on DCOracle new release that fixes many outstanding bugs. In addition, it is now integrated with the Zope2 transaction system. 2.0.0 This is the first version of the database adapter using DCOracle for Zope. This database adapter is based on an earlier database adapter for Principia, which is why this is revision 2. chas wrote:
I've got 8000 photos (jpeg format) stored in an Oracle database. The table that contains the photos has these columns which are of interest :
PICTURE LONG RAW PICTURE_LENGTH NOT NULL NUMBER(14)
My goals in order of progression are :
1. Extract the image from the database using ZSQL methods
2. Serve that image up directly to the web browser
3. Save the image to the filesystem or, even better, create a Zope Image Object
Unfortunately, I'm stuck at step 1. Doing a request on the database with ZSQL methods is returning :
Error, oci.error: (911, 'ORA-00911: invalid character\012')
Is there any way for Zope to handle this or is this going to involve python-DCOracle scripts instead and then uploading into Zope ?
Thank you very much in advance,
chas
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Digital Creations, Inc. Zope - http://www.zope.org
Chas, We extract LOBs from Oracle successfully every day, although not from DTML. We're using ZOracleDA 2.1.0 with DCOracle version 1.2.1 (I think). I'd recommend grabbing the latest version of ZOracleDA if you are starting out fresh. Look at the docs/docstrings/README for DCOracle (not ZOracleDA) for a description of how LOB access works. In short, I just added the LOB column to my query and got a big string with the data in it as a return value. There is another mode of operation in which you get an object from which you have to read data before you can use it. I would hazard to say that serving images directly from Oracle is going to be fairly slow. Depending on the performance you require and the load you expect, you might do better using an approach such as we outlined in our presentation at IPC8 (http://www.zope.org/Members/reedwade/IPC8/) of using Zope as a read-through cache for Oracle. This has worked very well for us for our needs. Good luck, Doug -- ----------------------------------------------------------------------------- Doug Hellmann Healtheon / WebMD Software Engineer http://www.webmd.com
Yikes, just noticed this one sat in my outbox unqueued : Going back a month, just have to say thank you Chris. It does work - I was getting the earlier error messages due to being a bit ambitious and trying to display all of the images. Just for the record, to get it to work : 1. Create a ZSQL method <ZSQL_SelectPicture> to extract the binary data field ('picture') of one (1) image. That's the important part - one single image. Don't try to select several records for further logic processing. 2. Create a DTML method that returns nothing more than the BLOB data from the ZSQL method, with the correct content type. Eg. <dtml-call "RESPONSE.setHeader('content-type', 'image/jpeg')"><dtml-in ZSQL_SelectPicture><dtml-var picture></dtml-in> Accessing the DTML method directly will return the image. chas
I've never done it, and it's not well-documented (ie. I have no idea if it really works), but I believe the Oracle DA can retrieve BLOBS... Here the CHANGES.txt file from ZOracleDA:
Z Oracle DA Releases
2.2.0
Added a small feature that allows you to access LOBs in the Oracle database. To do this, you must have your maximum number of results set to '1'. Otherwise, it won't work.
In addition, several bugs were resolved.
2.1.0
Based on DCOracle new release that fixes many outstanding bugs. In addition, it is now integrated with the Zope2 transaction system.
2.0.0
This is the first version of the database adapter using DCOracle for Zope. This database adapter is based on an earlier database adapter for Principia, which is why this is revision 2.
chas wrote:
I've got 8000 photos (jpeg format) stored in an Oracle database. The table that contains the photos has these columns which are of interest :
PICTURE LONG RAW PICTURE_LENGTH NOT NULL NUMBER(14)
My goals in order of progression are :
1. Extract the image from the database using ZSQL methods
2. Serve that image up directly to the web browser
3. Save the image to the filesystem or, even better, create a Zope Image Object
Unfortunately, I'm stuck at step 1. Doing a request on the database with ZSQL methods is returning :
Error, oci.error: (911, 'ORA-00911: invalid character\012')
Is there any way for Zope to handle this or is this going to involve python-DCOracle scripts instead and then uploading into Zope ?
Thank you very much in advance,
chas
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Chris McDonough Digital Creations, Inc. Zope - http://www.zope.org
participants (3)
-
chas -
Chris McDonough -
Doug Hellmann