Here is the filesystem layout for this datastore. Note that the all of the pickles are pickles of basic Python objects, so can be unpickled in any version of Python with or without Sage or the Sage notebook installed. They are also not compressed, so are reasonably easy to read ASCII.
The filesystem layout is as follows. It mirrors the URL’s used by the Sage notebook server:
sage_notebook.sagenb
conf.pickle
users.pickle
home/
username0/
history.pickle
id_number0/
worksheet.html
worksheet_conf.pickle
cells/
data/
snapshots/
id_number1/
worksheet.html
worksheet_conf.pickle
cells/
data/
snapshots/
...
username1/
...
Bases: sagenb.storage.abstract_storage.Datastore
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)
Return the history log for the given user.
INPUT:
- username – string
OUTPUT:
- list of strings
OUTPUT:
- dictionary of user info
EXAMPLES:
sage: from sagenb.notebook.user import User
sage: users = {'admin':User('admin','abc','a@b.c','admin'), 'wstein':User('wstein','xyz','b@c.d','user')}
sage: from sagenb.storage import FilesystemDatastore
sage: ds = FilesystemDatastore(tmp_dir())
sage: ds.save_users(users)
sage: 'users.pickle' in os.listdir(ds._path)
True
sage: ds.load_users()
{'admin': admin, 'wstein': wstein}
Return worksheet with given id_number belonging to the given user.
INPUT:
- username – string
- id_number – integer
OUTPUT:
- a worksheet
INPUT:
- server –
Save the history log (a list of strings) for the given user.
INPUT:
- username – string
- history – list of strings
INPUT:
- users – dictionary mapping user names to users
EXAMPLES:
sage: from sagenb.notebook.user import User
sage: users = {'admin':User('admin','abc','a@b.c','admin'), 'xyz':User('xyz','myalksjf','b@c.d','user')}
sage: from sagenb.storage import FilesystemDatastore
sage: ds = FilesystemDatastore(tmp_dir())
sage: ds.save_users(users)
sage: 'users.pickle' in os.listdir(ds._path)
True
sage: ds.load_users()
{'admin': admin, 'xyz': xyz}
INPUT:
- worksheet – a Sage worksheet
- conf_only – default: False; if True, only save the config file, not the actual body of the worksheet
EXAMPLES:
sage: from sagenb.notebook.worksheet import Worksheet
sage: tmp = tmp_dir()
sage: W = Worksheet('test', 2, tmp, system='gap', owner='sageuser')
sage: from sagenb.storage import FilesystemDatastore
sage: DS = FilesystemDatastore(tmp)
sage: DS.save_worksheet(W)
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 import FilesystemDatastore
sage: tmp = tmp_dir()
sage: FilesystemDatastore(tmp).worksheets('foobar')
[]
sage: from sagenb.notebook.worksheet import Worksheet
sage: W = Worksheet('test', 2, tmp, system='gap', owner='sageuser')
sage: from sagenb.storage import FilesystemDatastore
sage: DS = FilesystemDatastore(tmp)
sage: DS.save_worksheet(W)
sage: DS.worksheets('sageuser')
[sageuser/2: [Cell 0; in=, out=]]