[Zope] flash<->zope<->zsql

hpinson@indepthl.com hpinson@indepthl.com
Fri, 4 Jan 2002 20:36:38 -0700


This works for me.  loadVariablesNum and getURL are the key.  

Is there a better way?  This seems to require two zope steps, when it should be 
one...

Assuming you've got the ZODBC database product installed:

****************************************

To Load variables into flash:

// In Flash, from a button instance...
on (release) {
    loadVariablesNum ("http://www.yourzopesite.com/zsqlMethods/loadData", 0);
}

# In Zope
Where loadData is a DTML method with this content:
<dtml-call expr="readDB(_)">

That loads a ZSQL method called readDB with the following SQL:
SELECT * FROM myTable
WHERE user_id = 1;

Your flash variables should populate with accociated db content.

****************************************

To write variables to a database from Flash:

// In Flash
on (release) {
    getURL 
("http://www.yourzopesite.com/zsqlMethods/runSQL?CASE_NUMBER="+CASE_N
UMBER+"&COUNTY="+COUNTY, "POST");
}

# In Zope
Where runSQL is a DTML method with this content:
<dtml-call expr="updateDB(_)">

That loads a ZSQL method called updateDB with the following SQL:
Title: updateDB
Connection ID: ODBC_database_connection
Arguments: CASE_NUMBER COUNTY

SQL:

UPDATE myTable
SET
CASE_NUMBER=<dtml-sqlvar CASE_NUMBER type=string>,
COUNTY=<dtml-sqlvar COUNTY type=string>
WHERE USER_ID = 1;

****************************************

Harlow Pinson
Indepth Learning
Email: hpinson@indepthl.com 
Web: http://www.indepthl.com
Voice: 505-994-2135
FAX: 208-475-7678