webshare
webshare
OPERATION
,
RESULT

The webshare statement perform record locking operations from a web publishing procedure.

Parameters

This statement has two parameters:

operation – operation to be performed.

result – name of variable to put the result into (for locklist and locked operations).

Description

This statement performs a record locking operation from a web publishing procedure. If a database has both the sharing and web publishing options enabled that database can be simultaneously accessed by Panorama users and over the web. Any changes made with the web interface will automatically appear in Panorama clients the next time they are synchronized, while changes made using the Panorama interface will immediately appear when the database is accessed from a web browser (no synchronization is needed in this case since the web interface accesses the server directly). In most cases you don’t have to worry about any of this, simply write your web procedures as described in this chapter and everything will work fine.

### Web Publishing vs. Record Locking

Panorama Enterprise’s web publishing interface does not automatically do record locking. A web user can modify a record even if it is currently locked by a Panorama user, and a Panorama user can lock a record that is currently being edited by a web user. (In addition, two web users can both edit the same record simultaneously). In each of these cases the “winner” will be whoever changes the record last.

#### Manually Locking and Unlocking Records

A web procedure can use the webshare statement to manually lock or unlock a record. For example, if a procedure displays a form that allows a user to edit a record it can also lock the record.

    weburlselect cgiExtraParameters
    webshare "lock"
    if error
        /* record was already locked, so we can’t edit it now */
        cgiHTML = renderwebform("Record Lock","")
        rtn
    endif
    cgiHTML = renderwebform("Edit Record","")

The procedure that processes the data when the Submit button is pressed must unlock the record.

    webformtodatabase “whatrecord=record_id”
    webshare "unlock"

However, there’s potentially a serious problem with this technique — what if the user never presses the Submit button? If they walk away from the computer (or simply click away to another web page) the record will never be unlocked, and no one else can ever edit it (though this can be cleared using the Server Adminis-tration wizard). This is the reason why the web publishing interface does not automatically lock records.

#### Checking Record Lock Status

The webshare statement can also be used to find out the status of locked records. Use the “locked” option to find out if the current record is locked.

    local rlock
    webshare "locked",rlock
    if rlock=true()
        /* uh-oh, this record is locked */
        cgiHTML = renderwebform("Record Lock","")
        rtn
    endif
    /* continue with program */

Use the “locklist” option to get a list of all currently locked records. This procedure selects all locked records.

    local busyrecords
    webshare "locked",busyrecords
    select arraycontains(busyrecords,str("serverrecordid"),¶)

This list will contain the record ID numbers of all currently locked records, one per line. (You can use the info(“serverrecordid”) function to determine the record ID of the current record, as shown above.)

See Also

- closeserverfile -- closes the current database (used on the server).
- getcookie( -- returns the value of a cookie submitted to the server.
- getcookielist( -- returns a list of cookies submitted to the server.
- openserverfile -- opens a database (used on the server).
- setcookie -- set the value of a cookie to send back to the client..
- Web Cookies -- web cookies.
- webformitemvalue( -- gets the value of a POST web form item (used when processing a web query with Panorama Server).
- webimagedisplay( -- used within an Image Display Object to specify both a web image (used when the form is displayed in a web browser from Panorama Server) and a local image file (used when the form is displayed within Panorama).

History

Version | Status | Notes
10.2 | Updated | Carried over from Panorama 6.0.