<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Martijn Pieters wrote:
<blockquote cite="mid44FF53B4.7090904@zopatista.com" type="cite">
<pre wrap="">cpdm cadlab wrote:
</pre>
<blockquote type="cite">
<pre wrap=""> thanks for the quick reply. I am glad to be here on active ZOPE
mailing list.
</pre>
</blockquote>
<pre wrap=""><!---->
Let's keep it on the list then; no personal email please.
</pre>
<blockquote type="cite">
<pre wrap=""> I had initially done the way you have suggested, but it doesn't work
in the sense I get a empty list as output, which I know isn't empty.
</pre>
</blockquote>
<pre wrap=""><!---->
Then something is wrong with the external method. Use a debugger (pdb,
Wing, Komodo, etc.) or spurious logging (import logger;
logger.getLogger('yourmodule').log) to trace your code.
</pre>
<blockquote type="cite">
<pre wrap="">This made me think that I was making silly mistake. If I run external
method in python shell it shows the mlist, which is non-empty, but if I
ask the same to python script to do what it prints is this : []
What do you think is wrong. A further code goes like this:
mlist = context.code(uparam)
if len(mlist) == str(0):
print "Sorry no suitable method found in database"
return printed
else:
print mlist
return printed
</pre>
</blockquote>
<pre wrap=""><!---->
Use "if not len(mlist):"; comparing the length to str(0) is always
false. "len" returns an integer, not a string, so 0 == '0' will never be
True.
You can also call the external method directly if you encode the
arguments passed to it in the query string. Just open up a python
propmt, import urllib and call urllib.quote on your argument list to
hand-construct a URL.
Moreover, get decent books on Python and on Web programming in general.
Martijn Pieters
</pre>
</blockquote>
Martijn,<br>
<br>
I wonder which books would recommend? Best I can say is that books
just about HTTP are probably the least appreciated and often the most
useful.<br>
<br>
David<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>