[Zope] Display images stored in Relational DB

Thomas G. Apostolou thomas.info at hol.gr
Tue Oct 18 06:49:53 EDT 2005


Hello all,

I try to display some images stored in SQL Server 2K.
What i do is:

I have an External Method "GetPrList" witch is connected to a python
module that reads like this
def GetPrListData(self, sysDSN="Test_A_Voisys", usr="sa",
mypass="voisys"):
	id = self.id
	import dbi
	import odbc
	connection=odbc.odbc(sysDSN+'/'+usr+'/'+mypass)
	cur=connection.cursor()
	sSQL='SELECT M.CODE,M.NAME,X.SODATA FROM dbo.MTRL M JOIN
dbo.XTRDOCDATA
X ON M.MTRL=X.REFOBJID WHERE X.SOSOURCE=51 AND M.MTRGROUP=3'
	cur.execute(sSQL)
	data=cur.fetchall()
	cur.close()
	connection.close()
	return data

X.SODATA is jpg stored in SQL 2K in a field degined as	[SODATA] [image]
NULL

The above select returns -executed from within PythonWin- the folowing:
[('ACC.ART.0001', 'xd3xc5xd4 xc2xc9xc4xc5xd3 &
xd0xc1xcexc9xccxc1xc4xc9xc1 xccxc5 xc5xcbxc1xd4 andy',
<DbiRaw object at 0x0099D2A0>), ('ACC.CO3.0001', 'BATTERY
xccxcfxcbxd5xc2xc4xcfxd5 12V', <DbiRaw object at 0x0099D2D0>),
('ACC.CO3.0002', 'MExcbxc1xcdxc9 xcfxcaxc9 10i/12i/14e', <DbiRaw
object at 0x0099D2C0>)]

Then from a DTML Method "ShowResults" i call the above External Method
"GetPrList" and show its results in a table.
ShowResults reads like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      lang="en">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<script type="text/javascript"
src="/plone_javascript_variables.js"></script>
<script type="text/javascript" src="/plone_javascripts.js"></script>
    <!-- Column style sheet. -->
    <style type="text/css" media="screen"><!-- @import
url(/ploneColumns.css); --></style>
    <!-- Main style sheets for CSS2 capable browsers -->
    <style type="text/css" media="screen"><!-- @import url(/plone.css);
--></style>
    <!-- Custom style sheet if available -->
    <style type="text/css" media="all"><!-- @import
url(/ploneCustom.css); --></style>
    <!-- Disable IE6 image toolbar -->
    <meta http-equiv="imagetoolbar" content="no" />
</head>
<dtml-var standard_html_header>
<table id="sortable" class="listing" summary="Content listing"
cellpadding="0" cellspacing="0">
  <thead>
    <tr>
      <th class="">
        Κωδικός
      </th>
      <th class="">
        Ονομασία
      </th>
      <th class="">
        Εικόνα
      </th>
    </tr>
  </thead>
  <tbody>
    <dtml-in expr="GetPrList(sysDSN=dsnName, usr=usrID,
mypass=passWD)">
      <dtml-if sequence-even>
        <tr class="even">
      <dtml-else>
        <tr class="odd">
      </dtml-if>
      <dtml-in sequence-item>
        <td><dtml-var sequence-item> </td>
      </dtml-in>
      </tr>
    </dtml-in>
  </tbody>
</table>
<dtml-var standard_html_footer>

dsnName, usrID, passWD are properties with values of a folder i use
with
aquisition when i call DTML Method "ShowResults"

The problem is that i get a "pythonw.exe" Debug-Send Error Report-Don't
Send window and zope server breaks down. ( yes i use windows Xp Pro,
Zope 2.7.0, Python 2.3.3)

Thanks in advance


Thomas G. Apostolou
Software Engineer
Θωμάς Γ. Αποστόλου
Μηχανικός Λογισμικού



More information about the Zope mailing list