AUTHORS:
- William Stein
Bases: object
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Change the display name of the worksheet if there is already a worksheet with the same name as this one.
The default color scheme for the notebook.
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Create the default users for a notebook.
INPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: list(sorted(nb.user_manager().users().iteritems()))
[('_sage_', _sage_), ('admin', admin), ('guest', guest), ('pub', pub)]
sage: list(sorted(nb.user_manager().passwords().iteritems())) #random
[('_sage_', ''), ('admin', ''), ('guest', ''), ('pub', '')]
sage: nb.create_default_users('newpassword')
WARNING: User 'pub' already exists -- and is now being replaced.
WARNING: User '_sage_' already exists -- and is now being replaced.
WARNING: User 'guest' already exists -- and is now being replaced.
WARNING: User 'admin' already exists -- and is now being replaced.
sage: list(sorted(nb.user_manager().passwords().iteritems())) #random
[('_sage_', ''), ('admin', ''), ('guest', ''), ('pub', '')]
sage: len(list(sorted(nb.user_manager().passwords().iteritems())))
4
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Delete all files related to this notebook.
This is used for doctesting mainly. This command is obviously VERY dangerous to use on a notebook you actually care about. You could easily lose all data.
EXAMPLES:
sage: tmp = tmp_dir(ext='.sagenb')
sage: nb = sagenb.notebook.notebook.Notebook(tmp)
sage: sorted(os.listdir(tmp))
['home']
sage: nb.delete()
Now the directory is gone.:
sage: os.listdir(tmp)
Traceback (most recent call last):
...
OSError: [Errno 2] No such file or directory: '...
x.__init__(...) initializes x; see help(type(x)) for signature
Delete the given worksheet and remove its name from the worksheet list. Raise a KeyError, if it is missing.
INPUT:
x.__init__(...) initializes x; see help(type(x)) for signature
Empty the trash for the given user.
INPUT:
This empties the trash for the given user and cleans up all files associated with the worksheets that are in the trash.
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.user_manager().add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.new_worksheet_with_title_from_text('Sage', owner='sage')
sage: W._notebook = nb
sage: W.move_to_trash('sage')
sage: nb.worksheet_names()
['sage/0']
sage: nb.empty_trash('sage')
sage: nb.worksheet_names()
[]
Export a worksheet, creating a sws file on the file system.
INPUT:
worksheet_filename - a string e.g., ‘username/id_number’
output_filename - a string, e.g., ‘worksheet.sws’
- title - title to use for the exported worksheet (if
None, just use current title)
We should only call this if the user is admin!
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Get the worksheet with the given filename. If there is no such worksheet, raise a KeyError.
INPUT:
OUTPUT:
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Return the HTML for a worksheet’s index page.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: nb.html(W.filename(), 'admin')
u'...Test...cell_input...if (e.shiftKey)...state_number...'
Return HTML for a given worksheet’s post-publication page.
INPUT:
OUTPUT:
Return HTML for the warning and decision page displayed prior to publishing the given worksheet.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: nb.html_beforepublish_window(W, 'admin')
u'...want to publish this worksheet?...re-publish when changes...'
Return the HTML for the download or delete datafile page.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: nb.html_download_or_delete_datafile(W, 'admin', 'bar')
u'...Data file: bar...DATA is a special variable...uploaded...'
Return HTML for a window for editing worksheet.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: nb.html_edit_window(W, 'admin')
u'...textarea class="plaintextedit"...{{{id=1|...//...}}}...'
Return HTML for the window that displays a plain text version of the worksheet.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: nb.html_plain_text_window(W, 'admin')
u'...pre class="plaintext"...cell_intext...textfield...'
Return the HTML for the “share” page of a worksheet.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: nb.html_share(W, 'admin')
u'...currently shared...add or remove collaborators...'
Return the HTML for a specific revision of a worksheet.
INPUT:
OUTPUT:
Return HTML for the “Upload Data” window.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: nb.html_upload_data_window(W, 'admin')
u'...Upload or Create Data File...Browse...url...name of a new...'
Return HTML for the revision list of a worksheet.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: W = nb.create_new_worksheet('Test', 'admin')
sage: W.body()
u'\n\n{{{id=1|\n\n///\n}}}'
sage: W.save_snapshot('admin')
sage: nb.html_worksheet_revision_list('admin', W)
u'...Revision...Last Edited...ago...'
Import a worksheet with the given filename and set its owner. If the file extension is not recognized, raise a ValueError.
INPUT:
OUTPUT:
EXAMPLES:
We create a notebook and import a plain text worksheet into it.
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: name = tmp_filename() + '.txt'
sage: open(name,'w').write('foo\n{{{\n2+3\n}}}')
sage: W = nb.import_worksheet(name, 'admin')
W is our newly-created worksheet, with the 2+3 cell in it:
sage: W.name()
u'foo'
sage: W.cell_list()
[TextCell 0: foo, Cell 1: in=2+3, out=]
Do not do anything on logout (so far).
In particular, do NOT stop all username‘s worksheets!
Find the next worksheet id for the given user.
Return a new worksheet process object with parameters determined by configuration of this notebook server.
x.__init__(...) initializes x; see help(type(x)) for signature
The default typeset setting for new worksheets for a given user or the whole notebook (if username is None).
TODO – only implemented for the notebook right now
x.__init__(...) initializes x; see help(type(x)) for signature
Publish a user’s worksheet. This creates a new worksheet in the ‘pub’ directory with the same contents as worksheet.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.load_notebook(tmp_dir(ext='.sagenb'))
sage: nb.user_manager().add_user('Mark','password','',force=True)
sage: W = nb.new_worksheet_with_title_from_text('First steps', owner='Mark')
sage: nb.worksheet_names()
['Mark/0']
sage: nb.create_default_users('password')
sage: nb.publish_worksheet(nb.get_worksheet_with_filename('Mark/0'), 'Mark')
pub/0: [Cell 1: in=, out=]
sage: sorted(nb.worksheet_names())
['Mark/0', 'pub/0']
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Returns True if the user is supposed to only be a read-only user.
Save this notebook server to disk.
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
The default math software system for new worksheets for a given user or the whole notebook (if username is None).
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Upgrade the model, if needed.
Return an instance of the User class given the username of a user in a notebook.
INPUT:
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.user_manager().create_default_users('password')
sage: nb.user('admin')
admin
sage: nb.user('admin').get_email()
''
sage: nb.user('admin').password() #random
'256$7998210096323979f76e9fedaf1f85bda1561c479ae732f9c1f1abab1291b0b9$373f16b9d5fab80b9a9012af26a6b2d52d92b6d4b64c1836562cbd4264a6e704'
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Returns self’s UserManager object.
EXAMPLES:
sage: n = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: n.user_manager()
<sagenb.notebook.user_manager.OpenIDUserManager object at 0x...>
Returns all worksheets owned by
Returns all worksheets viewable by
Return a list of users that can log in.
OUTPUT:
EXAMPLES:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.create_default_users('password')
sage: nb.valid_login_names()
['admin']
sage: nb.user_manager().add_user('Mark', 'password', '', force=True)
sage: nb.user_manager().add_user('Sarah', 'password', '', force=True)
sage: nb.user_manager().add_user('David', 'password', '', force=True)
sage: sorted(nb.valid_login_names())
['David', 'Mark', 'Sarah', 'admin']
Create a new worksheet with given id_number belonging to the user with given username, or return an already existing worksheet. If id_number is None, creates a new worksheet using the next available new id_number for the given user.
INPUT:
- username – string
- id_number - nonnegative integer or None (default)
x.__init__(...) initializes x; see help(type(x)) for signature
x.__init__(...) initializes x; see help(type(x)) for signature
Return a list of all the names of worksheets in this notebook.
OUTPUT:
EXAMPLES:
We make a new notebook with two users and two worksheets, then list their names:
sage: nb = sagenb.notebook.notebook.Notebook(tmp_dir(ext='.sagenb'))
sage: nb.user_manager().add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = nb.new_worksheet_with_title_from_text('Sage', owner='sage')
sage: nb.user_manager().add_user('wstein','sage','wstein@sagemath.org',force=True)
sage: W2 = nb.new_worksheet_with_title_from_text('Elliptic Curves', owner='wstein')
sage: nb.worksheet_names()
['sage/0', 'wstein/0']
Bases: dict
Load and return a notebook from a given directory. Create a new one in that directory, if one isn’t already there.
INPUT:
OUTPUT:
Replace an absolute path with a relative path, if possible. Otherwise, return the given path.
INPUT:
OUTPUT:
Back up and migrates an old saved version of notebook to the new one ()
Sort a given list on a given key, in a given order.
INPUT:
OUTPUT: