Sage Notebook Storage Abstraction Layer¶
-
class
sagenb.storage.abstract_storage.Datastore¶ Bases:
objectThe Sage Notebook storage abstraction layer abstract base class. Each storage abstraction layer derives from this.
-
create_worksheet(username, id_number)¶ 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()¶ 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)¶ 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)¶ Input the worksheet username/id_number from the file with given filename.
-
load_openid()¶
-
load_server_conf()¶
-
load_user_history(username)¶ Return the history log for the given user.
INPUT:
username– string
OUTPUT:
- list of strings
-
load_users()¶ OUTPUT:
- dictionary of user info
-
load_worksheet(username, id_number)¶ 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_openid(openid_dict)¶
-
save_server_conf(server_conf)¶
-
save_user_history(username, history)¶ Save the history log (a list of strings) for the given user.
INPUT:
username– stringhistory– list of strings
-
save_users(users)¶ INPUT:
users– dictionary mapping user names to users
-
save_worksheet(worksheet, conf_only=False)¶ INPUT:
worksheet– a Sage worksheetconf_only– default: False; if True, only save the config file, not the actual body of the worksheet
-
worksheets(username)¶ 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
-