<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">


<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=113154917-08102003><FONT face=Arial>Hey 
all,</FONT></SPAN></DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial>i can appreciate not 
wanting to leave wide-open sql calls,</FONT></SPAN></DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial>but when it comes to 
dynamic queries ...</FONT></SPAN></DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial>we usually just need to 
change the where clause.</FONT></SPAN></DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial>That way you're restricting 
the query to: "select * from x where "</FONT></SPAN></DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial>so your database is not at 
risk.</FONT></SPAN></DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial>ciao</FONT></SPAN></DIV>
<DIV><SPAN class=113154917-08102003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>On Wed, Apr 09, 2003 at 01:10:25PM +0200, Fernando Martins 
wrote:<BR>&gt;<I> Thanks for replying,<BR></I>&gt;<I> &gt;<BR></I>&gt;<I> &gt; 
It is quite easy.&nbsp; But you really, really, really don't want to do 
it.<BR></I>&gt;<I> &gt;<BR></I>&gt;<I> &gt; zsql method<BR></I>&gt;<I> &gt; 
variable_sql<BR></I>&gt;<I> &gt; parameter<BR></I>&gt;<I> &gt; 
command<BR></I>&gt;<I> &gt; body<BR></I>&gt;<I> &gt; &lt;dtml-var 
command&gt;<BR></I>&gt;<I> &gt;<BR></I>&gt;<I> <BR></I>&gt;<I> It took me a 
while to understand what you mean with this list of items. So,<BR></I>&gt;<I> 
for the record, the idea is to create a zsql method called variable_sql 
with</DIV></I>&gt;<I> a parameter called command and a body having only 
&lt;dtml-var command&gt;. The<BR></I>&gt;<I> zsql is called with a complete SQL 
statement from wherever you want.<BR></I><BR>Yes, exactly.<BR><BR>&gt;<I> 
<BR></I>&gt;<I> &gt; Now, what is wrong with this?<BR></I>&gt;<I> 
&gt;<BR></I>&gt;<I> &gt; Well, you have no security, whatsoever.&nbsp; Anyone 
who can access method<BR></I>&gt;<I> &gt; variable_sql can do anything that they 
want to our database.&nbsp; Even if<BR></I>&gt;<I> &gt; you somehow limit access 
to the method, you can't stop SQL injection.<BR></I>&gt;<I> &gt; And you can't 
debug the SQL, since you have no idea of what will be<BR></I>&gt;<I> &gt; 
executed.<BR></I>&gt;<I> &gt;<BR></I>&gt;<I> <BR></I>&gt;<I> Well, in my case is 
for an Intranet and it's essentially a prototype.<BR></I>&gt;<I> <BR></I>&gt;<I> 
&gt; Go to the trouble now.&nbsp; It will reduce your trouble 
later.<BR></I>&gt;<I> &gt;<BR></I><BR>I wrote a howto on doing this.&nbsp; This 
is a common idea _many_ new users<BR>have.&nbsp; I now deeply wish that I had 
not done so.&nbsp; This is very bad<BR>magic.&nbsp; It makes your life 
unpleasant for an unforseeable time in the<BR>future.&nbsp; And when you are 
prototyping is exactly the wrong time to do<BR>it!&nbsp; The problem is that you 
then have an unauditable mess that can be<BR>fixed only by throwing everything 
away.<BR><BR>I recommend that you do things in little steps.&nbsp; Start writing 
your<BR>application in ZPT (or DTML) and pythonscripts.&nbsp; Every time you 
need a<BR>SQL query, go off to the side, and write it.&nbsp; Test it from the 
SQL test<BR>tab.&nbsp; That way you are reasonably confident that it works 
before you put<BR>it in the ZPT.&nbsp; Put it in the ZPT.&nbsp; test 
again.&nbsp; Flesh out the ZPT.<BR>Test again.<BR><BR>One of the most pleasant 
parts of zope is the ease of continuous,<BR>informal, samll testing.&nbsp; Oh, 
things will get past you, but if you test<BR>as you develop, a lot less gets 
past you.&nbsp; I often test every time I<BR>create a new table row, or 
paragraph, or whatever.<BR><BR>Jim Penny<BR>&gt;<I> <BR></I>&gt;<I> 
Appreciated,<BR></I>&gt;<I> <BR></I>&gt;<I> Fernando<BR></I>&gt;<I> 
<BR></I>&gt;<I> PS: thanks also to Michal.<BR></I>&gt;<I> <BR></I>&gt;<I> 
<BR></I>&gt;<I> _______________________________________________<BR></I>&gt;<I> 
Zope-DB mailing list<BR></I>&gt;<I> <A 
href="mailto:Zope-DB@zope.org">Zope-DB@zope.org</A><BR></I>&gt;<I> <A 
href="http://mail.zope.org/mailman/listinfo/zope-db">http://mail.zope.org/mailman/listinfo/zope-db</A><BR></I>&gt;<I> 
<BR></I><BR><BR><BR><BR><BR><BR><BR>
<P><FONT face=Verdana color=#000080 size=1>Jason LeMonier</FONT> <BR><FONT 
face=Verdana color=#000080 size=1>Software Engineer</FONT> <BR><FONT 
face=Verdana color=#000080 size=1>Retail Technologies International</FONT> 
<BR><FONT face=Verdana color=#000080 size=1>Office&nbsp;&nbsp; 
916.605.7262</FONT> <BR><FONT face=Verdana color=#000080 size=1>Mobile&nbsp; 
415.595.0969</FONT> <BR><FONT face=Verdana color=#000080 
size=1>Fax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 916-914-2132</FONT> <BR><FONT 
face=Verdana color=#000080 size=1>jlemonier@RetailPro.com</FONT> </P><BR>
<DIV>&nbsp;</DIV></BODY></HTML>