Sage Notebook Storage Abstraction Layer

class sagenb.storage.abstract_storage.Datastore

Bases: object

The Sage Notebook storage abstraction layer abstract base class. Each storage abstraction layer derives from this.

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_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.

INPUT:

  • username – string
  • id_number – integer

OUTPUT:

  • a worksheet
save_server_conf(server_conf)
save_user_history(username, history)

Save the history log (a list of strings) for the given user.

INPUT:

  • username – string
  • history – list of strings
save_users(users)

INPUT:

  • users – dictionary mapping user names to users
save_worksheet(worksheet, conf_only=False)

INPUT:

  • worksheet – a Sage worksheet
  • conf_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')
...
NotImplementedError

Previous topic

Live Documentation in the Notebook

Next topic

A Filesystem-based Sage Notebook Datastore

This Page