Re: [Zope] Need Help--urgently

2006-09-07 Thread Martijn Pieters
cpdm cadlab wrote:
 Well sure it takes time to acquire etiquette for newcomer. I am stuck
 but hopefully will solve it out. thanks a lot to both of you.

See, the problem lies not with Zope in this case, but with general
python programming and web programming. So all I can do is give you
pointers; how to debug, and how to fill in more context to understand
what is going on.

Martijn Pieters
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Need Help--urgently

2006-09-07 Thread Chris Withers

cpdm cadlab wrote:

Well sure it takes time to acquire etiquette for newcomer.


1. read this:

http://www.catb.org/~esr/faqs/smart-questions.html

2. don't post in html to a non-html list

3. use a real name

4. eesh, that's some ugly-assed code you posted :-S

Chris


--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Need Help--urgently

2006-09-06 Thread Martijn Pieters

On 6 Sep 2006 22:27:14 -, cpdm cadlab [EMAIL PROTECTED] wrote:

context.code(uparam)

code is the id of external method which processes uparam and at the end has 
statement
return mlist
   this mlist is what I am interested in getting back. I want external method 
to return me this list to
my python script searchuparam.


The external method already returs the list to your python script.
Just store the result in a variable:

 returnedlist = contex.code(uparam)

--
Martijn Pieters
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Need Help--urgently

2006-09-06 Thread Jonathan



In your python script:

mlist = context.code(uparam)
do something with mlist here


In your external method:

def code(self, uparam):
 mlist = []
 process inputparameter, 
build mlist)

 return mlist


Simple!


hth

Jonathan



  - Original Message - 
  From: 
  cpdm cadlab 
  
  To: zope@zope.org 
  Sent: Wednesday, September 06, 2006 6:27 
  PM
  Subject: [Zope] Need Help--urgently
  I am sure it should be 
  trivial, but being newbee makes me shameless :) What I 
  am in need of is guideline about how to integrate python script and external 
  python method. I have a form through which I collect 
  user input and forward it to a python script, which concatenates input in 
  certain pattern and  feeds it to external method. Now external 
  method runs fine and puts the results in a list called mlist. What I want to 
  know is how  do I fetch the "return mlist" resulting 
  from external method back to the python script which gave the input to it for 
  processing. The python script is named which 
  searchuparam which gets user input from form and does something like 
  this:uparam = str(0) + "," + str(0) + "," + str(1) + "," + str(0) + "," + 
  str(0) + "," + str(DO) 
  \ + "," 
  + str(NL) + "," + str(0) + "," + str(0) + "," + str(0) + "," + str(0) 
  \ + "," 
  + str(TIME) + "," + str(WM) + "," + str(NOP) + "," + str(EXP) + "," + 
  str(GKH)context.code(uparam)code is the id of external method 
  which processes uparam and at the end has statement return 
  mlist this mlist is what I am interested in getting back. I 
  want external method to return me this list to my python script searchuparam. 
  I tried reading and did google last week but without success. Any help is 
  appreciated. TIA.yours md
  
  

  ___Zope maillist 
  - 
  Zope@zope.orghttp://mail.zope.org/mailman/listinfo/zope** 
  No cross posts or HTML encoding! **(Related lists - 
  http://mail.zope.org/mailman/listinfo/zope-announcehttp://mail.zope.org/mailman/listinfo/zope-dev 
  )
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Need Help--urgently

2006-09-06 Thread Martijn Pieters
cpdm cadlab wrote:
   thanks for the quick reply. I am glad to be here on active ZOPE
 mailing list.

Let's keep it on the list then; no personal email please.

   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.

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.

 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

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
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Need Help--urgently

2006-09-06 Thread David H




Martijn Pieters wrote:

  cpdm cadlab wrote:
  
  
  thanks for the quick reply. I am glad to be here on active ZOPE
mailing list.

  
  
Let's keep it on the list then; no personal email please.

  
  
  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.

  
  
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.

  
  
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

  
  
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
  

Martijn,

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.

David










___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: Re: [Zope] Need Help--urgently

2006-09-06 Thread cpdm cadlab

 


On Thu, 07 Sep 2006 David H wrote :
Martijn Pieters wrote:

cpdm cadlab wrote:
 
 thanks for the quick reply. I am glad to be here on active ZOPE
mailing list.
  

Let's keep it on the list then; no personal email please.

 
 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.
  

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.

 
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
  

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
 
Martijn,

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.

David

Well sure it takes time to acquire etiquette for newcomer. I am stuck but hopefully will solve it out. thanks a lot to both of you.

m.d.




___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )