Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Jython:replace value with another value

Posted by patni (patni), 16 May 2005
Following is the line in the script
self.body.addParameter('''deleteSelection''', '''31''')

Now I want to replace '31'  with repid

Where repid is a number reading from file.
#To get reportid from file in file system
f = open( '/root/sqatest/test_suites/scripts/avadhoot_scripts/id.txt', 'r' )
repid =
repid = repid.strip()
print repid

How I can do that?

Posted by admin (Graham Ellis), 16 May 2005

self.body.addParameter('''deleteSelection''', repid)  

If you're reading the repid variable outside the method in which this line of code occurs, you'll need to pass it in ....

Posted by patni (patni), 19 May 2005
self.body.addParameter('''deleteSelection''', repid)

Shows error while executing

Encountered an error: Server returned HTTP response code: 500 for URL:

Posted by admin (Graham Ellis), 19 May 2005
The you've probably not got the right value in repid or the result of doing the substitute causes the parameter to point to an incorrect URL.

I don't quite know how to say this.   I know you're new to Jython and it's a lot to learn, but I think there must be more effective ways for you to do so than by asking me hear about the code line by line - that's inefficient for me and inefficient for you too. This board is really intended to help out with those occasional problems that you can't get solved elsewhere rather then being an early "port of call" whenever an error message come us.  Can I make some suggestions.

a) I think you would benefit hugely from a Python course - have a look at ours (at or at those run by Mark Lutz (at - depending on where in the world you're located

b) Mark's book has a lot of Python coverage and there's a wide range of other books too.   We've got a list of all the Python books we have here in our library, and they're categories by level and with a description of what each one includes - see

Hope this helps ... please do feel free to continue to post up occasional difficult issues you find to this board, but please don't use it as a first resort;  if I see more than, perhaps, one or two questions a week then I start to feel that there must be a better way.

- Graham

Posted by patni (patni), 24 May 2005
I tried with this
self.body.addParameter('''deleteSelection''', repid)

But still Its not working.
Its not giving me any exception problem
But also its not deleting the report of specified report id

Posted by admin (Graham Ellis), 25 May 2005
I don't have enough evidence to be able to comment fully.  If this works with a constant value but fails when you use repid, have you checked what's in repid by printing it out?  Have you tried doing the substitute by hand and then seeing if it works?   I suspect that tests like these will lead you to the error; I don't think I can, as I suspect that the root cause of the error isn't listed within the sample code you've supplied.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho