[Seaside] Async Issue with DB Calls

Ron Teitelbaum Ron at USMedRec.com
Mon Nov 13 21:10:10 UTC 2006


Hello all,

I had an interesting problem.  I'm wondering what the impact is to using
async updates during non blocking calls.

I wrote a zipcode look up.  It works fine after the first time but when you
start up the image the first time it breaks.

What is happening is that I get the response back but the entire page except
for the update shows up.  

In my case it's the city and state fields that show up but nothing else.  So
what I get is when you type in a zip code the page disappears and only the
two returned fields show up.

Since it works after the first time I figured it must have something to do
with the database call and the logon, so I shut down the image, started it
back up and ran the query.  There is a bit of a delay the first time but it
does work.

My guess was that it was a problem with blocking, so I added a semaphore to
make sure that seaside didn't return with the async while squeak called out
to the db.  

html tableRow with: [
	html tableData with: [html text: 'Zip: ']. 
	html tableData with: [
		html textInput on: #zip of: self address; size: 50;
			liveCallback: [:event :h | 
				self class accessSemaphore critical: [   
					aZip := ZipCodes selectForZipCode:
event.
				].
				aZip ifNotNil: [
					self address city: aZip city.
					self address state: aZip state.
				].
				h tableData id: #city; with: [h textInput
on: #city of: self address; size: 50].
				h tableData id: #state; with: [h textInput
on: #state of: self address; size: 50].
			]
		].
	].

This worked and solved my problem.  So my questions are.  How sensitive is
async to the system returning?  Do I need to have a blocking call for all
external calls within async?  Any idea why it works the second time without
the semaphore?  Is there some time limit or something that I've missed that
causes async to return even though squeak is still processing the callback?

Thanks for your help!

Ron Teitelbaum
President / Principal Software Engineer
US Medical Record Specialists
Ron at USMedRec.com 



More information about the Seaside mailing list