Sage Notebook Storage Abstraction Layer¶
Sage Notebook Storage Abstraction Layer
-
class
sagenb.storage.abstract_storage.
Datastore
[source]¶ Bases:
object
The Sage Notebook storage abstraction layer abstract base class. Each storage abstraction layer derives from this.
-
create_worksheet
(username, id_number)[source]¶ Create worksheet with given id_number belonging to the given user.
If the worksheet already exists, return ValueError.
INPUT:
username
– stringid_number
– integer
OUTPUT:
- a worksheet
-
delete
()[source]¶ Delete all files associated with this datastore. Dangerous! This is only here because it is useful for doctesting.
-
export_worksheet
(username, id_number, filename, title)[source]¶ Export the worksheet with given username and id_number to the given filename (e.g., ‘worksheet.sws’).
INPUT:
title
- title to use for the exported worksheet (if- None, just use current title)
-
import_worksheet
(username, id_number, filename)[source]¶ Input the worksheet username/id_number from the file with given filename.
-
load_user_history
(username)[source]¶ Return the history log for the given user.
INPUT:
username
– string
OUTPUT:
- list of strings
-
load_worksheet
(username, id_number)[source]¶ Return worksheet with given id_number belonging to the given user.
If the worksheet does not exist, return ValueError.
INPUT:
username
– stringid_number
– integer
OUTPUT:
- a worksheet
-
save_user_history
(username, history)[source]¶ Save the history log (a list of strings) for the given user.
INPUT:
username
– stringhistory
– list of strings
-
save_worksheet
(worksheet, conf_only=False)[source]¶ INPUT:
worksheet
– a Sage worksheetconf_only
– default: False; if True, only save the config file, not the actual body of the worksheet
-
worksheets
(username)[source]¶ Return list of all the worksheets belonging to the user with given name. If the given user does not exists, an empty list is returned.
EXAMPLES: The load_user_data function must be defined in the derived class:
sage: from sagenb.storage.abstract_storage import Datastore sage: Datastore().worksheets('foobar') Traceback (most recent call last): ... NotImplementedError
-