[Zope] Newbie SQL method problems

Joseph Kocherhans joseph@aspen-net.com
Wed, 2 Feb 2000 17:09:24 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_0178_01BF6DA0.412E1FC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have a ZSQL method that take 1 input category_id:
    select * from category_names where id=3D<dtml-sqlvar category_id =
type=3Dint>

The folder containing the method has a property category_id.

If I leave the arguments feild of the SQL method blank then the method =
displays correctly. However if I put category_id in the arguments feild =
I get this error:
Zope has encountered an error while publishing this resource.=20
Error Type: Bad Request
Error Value: ['category_id']
Traceback (innermost last):
  File C:\Program Files\ecomdev\lib\python\ZPublisher\Publish.py, line =
214, in publish_module
  File C:\Program Files\ecomdev\lib\python\ZPublisher\Publish.py, line =
179, in publish
  File C:\Program Files\ecomdev\lib\python\Zope\__init__.py, line 202, =
in zpublisher_exception_hook
    (Object: ElementWithAttributes)
  File C:\Program Files\ecomdev\lib\python\ZPublisher\Publish.py, line =
165, in publish
  File C:\Program Files\ecomdev\lib\python\ZPublisher\mapply.py, line =
160, in mapply
    (Object: index_html)
  File C:\Program Files\ecomdev\lib\python\ZPublisher\Publish.py, line =
102, in call_object
    (Object: index_html)
  File C:\Program Files\ecomdev\lib\python\OFS\DTMLDocument.py, line =
166, in __call__
    (Object: index_html)
  File C:\Program =
Files\ecomdev\lib\python\DocumentTemplate\DT_String.py, line 502, in =
__call__
    (Object: index_html)
  File C:\Program Files\ecomdev\lib\python\OFS\DTMLDocument.py, line =
162, in __call__
    (Object: home)
  File C:\Program =
Files\ecomdev\lib\python\DocumentTemplate\DT_String.py, line 502, in =
__call__
    (Object: home)
  File C:\Program Files\ecomdev\lib\python\DocumentTemplate\DT_In.py, =
line 630, in renderwob
    (Object: category_names)
  File C:\Program Files\ecomdev\lib\python\Shared\DC\ZRDB\DA.py, line =
396, in __call__
    (Object: category_names)
  File C:\Program Files\ecomdev\lib\python\Shared\DC\ZRDB\Aqueduct.py, =
line 149, in _argdata
    (Object: category_names)
Bad Request: (see above)

In the ZSQL Method User guide it explains that if a variable is present =
in the arguments list then Zope looks at the HTTP request first and if =
it doesn't find the variable it looks at the properties of the method's =
containing folder. =
http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.4.4.html#pgfld-=
915825

If I pass the variable category_id in a form or a URL then the SQL =
method displays correctly.

I appears to me (please prve me wrong) that Zope is not performing the =
second lookup. Has anyone else had a problem similar to this? Please let =
me know if I am not explaining it well enough.

Thanks in advance!
=20


------=_NextPart_000_0178_01BF6DA0.412E1FC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2919.6307" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I have a ZSQL method that take 1 input=20
category_id:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; select * from =
category_names=20
where id=3D&lt;dtml-sqlvar category_id type=3Dint&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The folder containing the method has a =
property=20
category_id.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>If I leave the arguments feild of the =
SQL method=20
blank then the method displays correctly. However if I put category_id =
in the=20
arguments feild I get this error:</FONT><FONT face=3DArial =
size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Zope has encountered an error while =
publishing this=20
resource. </DIV>
<DIV>
<P><STRONG>Error Type: Bad Request</STRONG><BR><STRONG>Error Value:=20
['category_id']</STRONG><BR>Traceback (innermost last):<BR>&nbsp; File=20
C:\Program Files\ecomdev\lib\python\ZPublisher\Publish.py, line 214, in=20
publish_module<BR>&nbsp; File C:\Program=20
Files\ecomdev\lib\python\ZPublisher\Publish.py, line 179, in =
publish<BR>&nbsp;=20
File C:\Program Files\ecomdev\lib\python\Zope\__init__.py, line 202, in=20
zpublisher_exception_hook<BR>&nbsp;&nbsp;&nbsp; (Object:=20
ElementWithAttributes)<BR>&nbsp; File C:\Program=20
Files\ecomdev\lib\python\ZPublisher\Publish.py, line 165, in =
publish<BR>&nbsp;=20
File C:\Program Files\ecomdev\lib\python\ZPublisher\mapply.py, line 160, =
in=20
mapply<BR>&nbsp;&nbsp;&nbsp; (Object: index_html)<BR>&nbsp; File =
C:\Program=20
Files\ecomdev\lib\python\ZPublisher\Publish.py, line 102, in=20
call_object<BR>&nbsp;&nbsp;&nbsp; (Object: index_html)<BR>&nbsp; File =
C:\Program=20
Files\ecomdev\lib\python\OFS\DTMLDocument.py, line 166, in=20
__call__<BR>&nbsp;&nbsp;&nbsp; (Object: index_html)<BR>&nbsp; File =
C:\Program=20
Files\ecomdev\lib\python\DocumentTemplate\DT_String.py, line 502, in=20
__call__<BR>&nbsp;&nbsp;&nbsp; (Object: index_html)<BR>&nbsp; File =
C:\Program=20
Files\ecomdev\lib\python\OFS\DTMLDocument.py, line 162, in=20
__call__<BR>&nbsp;&nbsp;&nbsp; (Object: home)<BR>&nbsp; File C:\Program=20
Files\ecomdev\lib\python\DocumentTemplate\DT_String.py, line 502, in=20
__call__<BR>&nbsp;&nbsp;&nbsp; (Object: home)<BR>&nbsp; File C:\Program=20
Files\ecomdev\lib\python\DocumentTemplate\DT_In.py, line 630, in=20
renderwob<BR>&nbsp;&nbsp;&nbsp; (Object: category_names)<BR>&nbsp; File=20
C:\Program Files\ecomdev\lib\python\Shared\DC\ZRDB\DA.py, line 396, in=20
__call__<BR>&nbsp;&nbsp;&nbsp; (Object: category_names)<BR>&nbsp; File=20
C:\Program Files\ecomdev\lib\python\Shared\DC\ZRDB\Aqueduct.py, line =
149, in=20
_argdata<BR>&nbsp;&nbsp;&nbsp; (Object: category_names)<BR>Bad Request: =
(see=20
above)</P>
<P>In the ZSQL Method User guide it explains that if a variable is =
present in=20
the arguments list then&nbsp;Zope looks at the HTTP request first and if =
it=20
doesn't find the variable it looks at the properties of the method's =
containing=20
folder. <A=20
href=3D"http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1.4.4.htm=
l#pgfld-915825">http://www.zope.org/Documentation/Guides/ZSQL-HTML/ZSQL.1=
.4.4.html#pgfld-915825</A></P>
<P>If I pass the variable category_id in a form or a URL then the SQL =
method=20
displays correctly.</P>
<P>I appears to me (please prve me wrong) that Zope is not performing =
the second=20
lookup. Has anyone else had a problem similar to this? Please let me =
know if I=20
am not explaining it well enough.</P>
<P>Thanks in advance!<BR>&nbsp;</P></FONT></DIV></BODY></HTML>

------=_NextPart_000_0178_01BF6DA0.412E1FC0--