Module h2o_wave.core
Functions
clone_expando
Clone an expando instance. Creates a shallow clone.
- Args
- -----=
source- The expando to clone.
exclude_keys- Keys to exclude while cloning.
include_keys- Keys to include while cloning.
Returns -----= The expando clone.
copy_expando
Copy all entries from the source expando instance to the target expando instance.
- Args
- -----=
source- The expando to copy from.
target- The expando to copy to.
exclude_keys- Keys to exclude while copying.
include_keys- Keys to include while copying.
Returns -----= The target expando.
data
Create a Data instance for associating data with cards.
data()(fields, size) creates a placeholder for data and allocates memory on the Wave server.
data()(fields, size, rows) creates a placeholder and initializes it with the provided rows.
If pack() is True, the size parameter is ignored, and the function returns a packed string representing the data.
- Args
- -----=
fields- The names of the fields (columns names) in the data, either a list or tuple or string containing space-separated names.
size- The number of rows to allocate memory for. Positive for fixed buffers, negative for cyclic buffers and zero for variable length buffers.
rows- The rows in this data.
columns- The columns in this data.
pack- True to return a packed string representing the data instead of a
Dataplaceholder. t- Buffer type. One of 'list', 'map', 'cyclic' or 'fixed'. Overrides the buffer type inferred from the size.
Returns -----= Either a Data placeholder or a packed string representing the data.
expando_to_dict
Extract an expando's underlying dictionary. Any modifications to the dictionary also affect the original expando.
- Args
- -----=
e- The expando instance.
Returns -----= The expando's dictionary.
marshal
Marshal to JSON.
- Args
- -----=
d- Any object or value.
Returns -----= A string containing the JSON-serialized form.
pack
Pack (compress) the provided value.
- Args
- -----=
data- Any object or value.
The object or value compressed into a string.
unmarshal
Unmarshal a JSON string.
- Args
- -----=
s- A string containing JSON-serialized data.
Returns -----= The deserialized object or value.
Classes
AsyncPage
Represents a reference to a remote Wave page. Similar to Page except that this class exposes async methods.
- Args
- -----=
site- The parent site.
url- The URL of this page.
Methods
load
Retrieve the serialized form of this page from the remote site.
Returns -----= The serialized form of this page
save
Save the page. Sends all local changes made to this page to the remote site.
Ancestors
Inherited members
AsyncSite
Represents a reference to the remote Wave site. Similar to Site except that this class exposes async methods.
Methods
download
Download a file from the site.
- Args
- -----=
url- The URL of the file.
path- The local directory or file path to download to. If a directory is provided, the original name of the file is retained.
Returns -----= The path to the downloaded file.
load
Retrieve data at the given URL, typically the serialized form of a page.
- Args
- -----=
url- The URL to read.
Returns -----= The serialized page.
proxy
unlink
Signal the end of a stream.
- Args
- -----=
path- The path of the stream
unload
Delete an uploaded file from the site.
- Args
- -----=
url- The URL of the file to delete.
uplink
Create or update a stream of images.
The typical use of this function is to transmit a stream of images to a web page, providing the appearance of a video. The path returned by this function can be passed to ui.image() or ui.image_card() (or even a custom HTML img element). The stream is displayed in browsers using multipart/x-mixed-replace content. Callers must call the unlink() function to signal end-of-stream.
- Args
- -----=
path- a unique path or name for the stream (e.g. 'foo/bar/qux.png'). Must be a valid URL path.
content_type- The MIME type of the streamed content (e.g. 'image/jpeg', 'image/png', etc.).
file- A file or file-like object (on-disk file, standard I/O, in-memory buffers, sockets or pipes).
Returns -----= The stream endpoint, typically used as an image path.
upload
Upload local files to the site.
- Args
- -----=
files- A list of file paths of the files to be uploaded.
Returns -----= A list of remote URLs for the uploaded files, in order.
upload_dir
WARNING: Experimental and subject to change. Upload whole directory to the site with directory structure preserved.
- Args
- -----=
directory- Folder to be uploaded.
Returns -----= A list of remote URLs for the uploaded directory (always size of 1).
Data
Represents a data placeholder. A data placeholder is used to allocate memory on the Wave server to store data.
- Args
- -----=
fields- The names of the fields (columns names) in the data, either a list or tuple or string containing space-separated names.
size- The number of rows to allocate memory for. Positive for fixed buffers, negative for cyclic buffers and zero for variable length buffers.
data- Initial data. Must be either a key-row
dictfor variable-length buffers OR a rowlistfor fixed-size and cyclic buffers. t- Buffer type. One of 'list', 'map', 'cyclic' or 'fixed'. Overrides the buffer type inferred from the size.
Methods
dump
Expando
Represents an object whose members (attributes) can be dynamically added and removed at run time.
- Args
- -----=
args- An optional
dictof attribute-value pairs to initialize the expando instance with.
Page
Represents a reference to a remote Wave page.
- Args
- -----=
site- The parent site.
url- The URL of this page.
Methods
load
Retrieve the serialized form of this page from the remote site.
Returns -----= The serialized form of this page
save
Save the page. Sends all local changes made to this page to the remote site.
Ancestors
Inherited members
PageBase
Represents a remote page.
- Args
- -----=
url- The URL of the remote page.
Methods
add
Add a card to this page.
- Args
- -----=
key- The card's key. Must uniquely identify the card on the page. Overwrites any other card with the same key.
card- A card. Use one of the
ui.*_card()to create cards.
Returns -----= A reference to the added card.
drop
Delete this page from the remote site. Same as del site[url].
Subclasses
Ref
ServiceError
Common base class for all non-exit exceptions.
Ancestors
- builtins.Exception
- builtins.BaseException
Site
Represents a reference to the remote Wave site. A Site instance is used to obtain references to the site's pages.
Methods
download
Download a file from the site.
- Args
- -----=
url- The URL of the file.
path- The local directory or file path to download to. If a directory is provided, the original name of the file is retained.
Returns -----= The path to the downloaded file.
load
Retrieve data at the given URL, typically the serialized form of a page.
- Args
- -----=
url- The URL to read.
Returns -----= The serialized page.
proxy
unlink
Signal the end of a stream.
- Args
- -----=
path- The path of the stream
unload
Delete an uploaded file from the site.
- Args
- -----=
url- The URL of the file to delete.
uplink
Create or update a stream of images.
The typical use of this function is to transmit a stream of images to a web page, providing the appearance of a video. The path returned by this function can be passed to ui.image() or ui.image_card() (or even a custom HTML img element). The stream is displayed in browsers using multipart/x-mixed-replace content. Callers must call the unlink() function to signal end-of-stream.
- Args
- -----=
path- a unique path or name for the stream (e.g. 'foo/bar/qux.png'). Must be a valid URL path.
content_type- The MIME type of the streamed content (e.g. 'image/jpeg', 'image/png', etc.).
file- A file or file-like object (on-disk file, standard I/O, in-memory buffers, sockets or pipes).
Returns -----= The stream endpoint, typically used as an image path.
upload
Upload local files to the site.
- Args
- -----=
files- A list of file paths of the files to be uploaded..
Returns -----= A list of remote URLs for the uploaded files, in order.
upload_dir
WARNING: Experimental and subject to change. Upload whole directory to the site with directory structure preserved.
- Args
- -----=
directory- Folder to be uploaded.
Returns -----= A list of remote URLs for the uploaded directory (always size of 1).