Re: ACGI form parsing in OSX?
Re: ACGI form parsing in OSX?
- Subject: Re: ACGI form parsing in OSX?
- From: email@hidden
- Date: Fri, 1 Feb 2002 01:18:23 EST
I have 2 responses here:
James, I'm glad you're on board for getting ACGIs working in X. The handler
for parsing that you provided is incomplete. We (OK, I) need a way to deal
with the fact that form POST data arrives URL encoded. My experience is that
pure Applescript approaches to this are sloooooow.
With all this talk of the Unix, is there a way to do this with the shell?
Anyone?
Gabe wrote:
>
the other problem that i'm having is getting an applescript to continue
>
running after the return.
Two ways to interpret this. The correct answer to the exact way you asked the
question is to save the ACGI as a stay-open application, but you knew that
already and that's not what you meant anyway.
You meant "continue processing" after the return. The answer is NO. Once you
"return," you're done. There are some techniques to achieve your goals though
(these answers are based on experience with 8/9, but should be equally
applicable to OSX):
- pass the task to another stay-open script application, using "ignoring
application responses"
- have your idle handler do the work (may choke under load)
- use "send partial" (except I don't think this is implemented in WebSTAR V
yet. Dunno about OSX Server - what server are you using?)
But bottom line, when you "return," you're done.
Jeff Baumann
email@hidden
www.linkedresources.com
Full AS-ACGI support in OSX...
Victory in the War on Terrorism...
The second coming of Christ...
It's anyone's guess which will happen first.
In a message dated 1/31/02 3:02:12 PM, Gabe Benveniste wrote:
>
thanks for the help.
>
>
the other problem that i'm having is getting an applescript to continue
>
running after the return.
>
>
here's what i'm trying to do
>
>
script processes the forms
>
returns html to the user, or redirects them
>
process files on local machine based on form information
... and earlier had asked:
>
>> are there any scripting additions like parse CGI that work under OSX?
>
>>
>
>> I've looked at the parsing example on apple.com/applescript and can't
>
>> seem to figure out a simple way to set field values as variables.
>
>>
>
>> any help would be appreciated.
To whcih James Whistleblower Sentman responded:
>
> Do you mean how to parse the raw query string and/or post data that
>
> gets sent to you in an acgi script? If so then I might have some
>
> regular applescript code that would help. If I misunderstood the
>
> question, then this wont help;)
>
>
>
> property FormKeys : {}
>
> property FormValues : {}
>
>
>
> on ParseFormData(RawFormData)
>
> set FormKeys to {}
>
> set FormValues to {}
>
> set TemporaryArray to {}
>
> set SavedDelimiter to AppleScript's text item delimiters
>
> set AppleScript's text item delimiters to {"&"}
>
> set paircount to count of text items in RawFormData
>
>
>
> if RawFormData is equal to "" then
>
> return
>
> end if
>
>
>
> repeat with i from 1 to paircount
>
> set s to text item i of RawFormData
>
> set TemporaryArray to TemporaryArray & s
>
> end repeat
>
>
>
> set AppleScript's text item delimiters to {"="}
>
>
>
> set paircount to length of TemporaryArray
>
>
>
> repeat with i from 1 to paircount
>
> set thisName to text item 1 of (item i of TemporaryArray)
>
> set thisValue to text item 2 of (item i of TemporaryArray)
>
>
>
> set FormKeys to FormKeys & thisName
>
> set FormValues to FormValues & thisValue
>
> end repeat
>
>
>
> set AppleScript's text item delimiters to SavedDelimiter
>
>
>
> end ParseFormData
>
>
>
> on GetFormData(theKey)
>
> set thisCount to length of FormKeys
>
> repeat with i from 1 to thisCount
>
> if item i of FormKeys is equal to theKey then
>
> return item i of FormValues
>
> end if
>
> end repeat
>
>
>
> return ""
>
> end GetFormData
>
>
>
> Just pass the query string, or the post form data to the ParseFormData
>
> method. that will put the keys and values into 2 arrays. Then use the
>
> GetFormData method to find the key you are looking for and return the
>
> value from the form. Originally I felt that it should be a record
>
> instead of just a pair of arrays, the lookup would be faster, but I ran
>
> into name space problems when names from the forms ran into reserved
>
> words in apple script.
>
>
>
> I'm sure it could be done better, but this is very flexible. I'm using
>
> it with the iTunes control script example that I included with the acgi
>
> enabler program for OSX at: http://www.sentman.com/acgi
>
>
>
> Sorry if I misunderstood the question.
>
>
>
> -James