accessing javascript variables within psp code

2007-07-17 Thread BAnderton
Hello all,

Question:  Is there any way to access a javascript variable from
within psp code?


I'm aware of how to do the reverse of this (js_var='<%=psp_var%>').


Here's a non-working example of what I'm trying to do:


- - - (begin example) - - -


function Test(txt)
{
a = confirm('Are you sure you want to delete '+txt+'?')
if (a)
{
//The problem is getting the value of js variable 'txt' recognized in
"psp space".
<%
os.remove(  os.path.join(os.path.dirname(req.filename), '../notes/'+
%>txt<%)  )
%>


}
}


- - - (end example) - - -

FYI, I've already found a workaround for the above example (by placing
a "get" variable in the URL, reloading the page, and having psp check
for the existence of that variable before proceeding with deleting the
appropriate file) but I'd still like this general capability for
future projects.  I've searched several forums, websites, etc. and
the
answer has aluded me for two days now.  I'm new to apache, mod_python,
and javascript, so this may be ridiculously simple.

Since this is my first post on google groups, I'd also appreciate any
helpful suggestions on how to best go about getting answers quickly
(so let me know if there's a more appropriate forum/method/etc.)

Thanks for any help you can provide.



(This is copied from a message I originally posted to the mod_python
group.)

-- 
http://mail.python.org/mailman/listinfo/python-list


How to close all python-opened file identifiers?

2008-07-25 Thread BAnderton
Greetings from beautiful Tucson, Arizona.

Question:  Is there a way in Python to determine what all file
identifiers have been opened by Python, and to close them all?

Why I ask:  I learned Python after cutting my programming teeth on
Matlab, where you get a list of all open file identifiers (that is,
those opened from a particular Matlab session) with "fopen('all')" and
close them with "fclose('all')".  In my 4 years of experience with
Python, I haven't yet come across an equivalent means of doing this in
Python.  I understand that this problem can be prevented by  making
sure a "fid.close()" exists for every "open"; I need this however for
a file-permissions troubleshooting problem.

Extra info on this specific problem:  In my program, python (through
subprocess) launched a text editor on a text file, and I can't seem to
save the text file through that editor (I get a "this document is in
use by another application and cannot be accessed" error from the
editor [wordpad on winXp]).  The text file in question is modified by
my program prior to its loading into the launched editor.  Although I
can't find unmatched "open" and "fid.close()" statements, I'd like to
implement a check for open file identifiers before launching the
editor.

Thanks very much in advance for your time and any help you can provide.
--
http://mail.python.org/mailman/listinfo/python-list


Re: internet searching program

2008-08-10 Thread BAnderton
I was doing something very similar on my windows XP machine a year ago
(with python 2.4) and used Mayukh Bose's Internet Explorer controller
(see http://www.mayukhbose.com/python/IEC/index.php for details/
download).  It worked very nicely for my needs and was rather
intuitive (generally much easier and required fewer brain cells than
using urllib) ... here's some clips from the project:

# this window will be for our initial data pull-in
ie = IEController()
ie.Navigate('http://')
ie.ClickButton(caption='Advanced')
...
ie.SetInputValue('search_string',strUserID)
ie.ClickButton(name='image')
...
strAllText = ie.GetDocumentText() # gets all html source code
from current page.
...
ie.CloseWindow()

I wish someone could make a similar one for Firefox.
--
http://mail.python.org/mailman/listinfo/python-list