Object Wopi

General framework data and functions

object Wopi

more...

Summary

getAppData()Gets global, persistent web application data.
getPData()Gets local per-thread persistent data
sendTemplate()Configures template file and possibly sends it to the remote end.
setAppData()Sets global, persistent web application data.
setPData()Gets local per-thread persistent data.

Detailed description

object Wopi


General framework data and functions

This object allows to access to general purpose functions exposed by the framework, and to global framework settings.

A few utility function exposed by the Wopi model are directly exported to the main namespace for convenience and because they are widely used. Every other functionality is exposed through Request, Reply or Wopi.

Methods

getAppData()

Gets global, persistent web application data.

Wopi.getAppData( [app] )

appApplication name for the specific data.

This method restores application-wide data set through the Wopi.setData method. The optional parameter app may be specified to indicate a different applicaiton name under which the data are to be saved and restored.

See wopi_appdata for further details.

getPData()

Gets local per-thread persistent data

Wopi.getPData( id, [func] )

idUnique ID for persistent data.
funcFunction to create the data if it's not ready.
Returns:The previously saved item, or nil if not found.

This method restores process or thread specific persistent data that was previously saved, possibly during another execution and in another virtual machine, via Wopi.setPData.

An optional func parameter is called in case the data under the given id is not found; the return value of that function is then stored in the persistent data slot, as if Wopi.setPData was called with the same id to save the data, and is then returned to the caller of this method.

See wopi_pdata for further details.

sendTemplate()

Configures template file and possibly sends it to the remote end.

Wopi.sendTemplate( stream, [tpd], [inMemory] )

streamA Falcon stream opened for reading (or a memory string stream).
tpdData for template conversion.
inMemoryWork in memory and return the result instead sending it.
Returns: The configured contents of the file if inMemory is true.
Raises:
IoErroron error reading the file.

This function reads a text as-is (in binary mode) and flushes its contents to the remote side stream.

If a dictionary is set as template conversion data, the data in the file is converted so that strings between a pair of '%' symbols are expanded in the text coresponding to the key in the dictionary. In example, if this is a template file:

   My name is %name%, pleased to meet you!

The %name% configurable text may be changed into "John Smith" throught the following call:

   sendTemplate( InputStream("mytemplate.txt"), ["name" => "John Smith"] )

If a configurable text is not found in the tpd dictionary, it is removed. The specal sequence '%%' may be used to write a single '%'.

Note: Maximum lenght of template configurable strings is 64.

setAppData()

Sets global, persistent web application data.

Wopi.setAppData( data, [app] )

dataThe data to be saved (in a dictionary)
appApplication name for the specific data.
Returns:True if the synchronization with the application data was successful, false in case the data was already changed.

This method saves application-wide data, that can be retrieved elsewhere to have persistent data. The optional parameter app may be specified to indicate a different applicaiton name under which the data are to be saved and restored.

Note: Important: be sure that the data to be saved can be safely and directly serialized.

The function may return false if the synchronization failed. If you want to atomically receive the new contents of the data, pass it by reference.

See wopi_appdata for further details.

setPData()

Gets local per-thread persistent data.

Wopi.setPData( id, item )

idUnique ID for persistent data.
itemA data to be stored persistently.

This method saves process or thread specific data, to be retrieved, eventually by another virtual machine at a later execution under the same thread or process.

Persistent data is identified by an unique ID. An application can present different persistent data naming them differently.

Note: The id must be a valid string, including an empty string. So, "" can be used as a valid persistent key.

Setting the item to nil effectively removes the entry from the persistent storage. However, the data will be reclaimed (and finalized) during the next garbage collection loop.

See wopi_pdata for further details.


Made with faldoc 2.2.1