The Sage Notebook Twisted Web Server

TESTS:

It is important that this file never be imported by default on startup by Sage, since it is very expensive, since importing Twisted is expensive. This doctest verifies that twist.py isn’t imported on startup.:

sage: os.system("sage -startuptime | grep twisted\.web2 1>/dev/null") != 0  # !=0 means not found
True
class sagenb.notebook.twist.AddWorksheet

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.AdminAddUser(username)

Bases: twisted.web2.resource.PostableResource

render(request)
class sagenb.notebook.twist.AdminToplevel(cookie, username)

Bases: sagenb.notebook.twist.UserToplevel

userchild_adduser
alias of AdminAddUser
userchild_home
alias of WorksheetsAdmin
userchild_notebooksettings
alias of NotebookSettingsPage
userchild_users
alias of ListOfUsers
class sagenb.notebook.twist.AnonymousToplevel(cookie, username)

Bases: sagenb.notebook.twist.Toplevel

PasswordChecker
alias of PasswordChecker
render(ctx)
userchildFactory(request, name)
userchild_home
alias of Worksheets
userchild_pub
alias of PublicWorksheets
userchild_src
alias of SourceBrowser
class sagenb.notebook.twist.CSS

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.CellData(worksheet, number)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.Doc(username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.DocLive(username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.DocPDF

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.DocRefMedia

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.DocReference

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.DocStatic

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.DownloadWorksheets(username)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.EmptyTrash(username)

Bases: twisted.web2.resource.PostableResource

http_GET(request)
render(ctx)

Rendering this resource (1) empties the trash, and (2) returns a message.

EXAMPLES:

We create a notebook with a worksheet, put it in the trash, then empty the trash by creating and rendering this worksheet.:

sage: n = sagenb.notebook.notebook.load_notebook('notebook-test.sagenb')
sage: n.add_user('sage','sage','sage@sagemath.org',force=True)
sage: W = n.new_worksheet_with_title_from_text('Sage', owner='sage')
sage: W.move_to_trash('sage')
sage: n.worksheet_names()
['sage/0']
sage: sagenb.notebook.twist.notebook = n
sage: E = sagenb.notebook.twist.EmptyTrash('sage'); E
<sagenb.notebook.twist.EmptyTrash object at ...>
sage: from sagenb.notebook.twist import HTMLResponse
sage: ctx = HTMLResponse(stream = 'foo')
sage: ctx.headers.addRawHeader('referer', 'over there')
sage: E.render(ctx)
<sagenb.notebook.twist.RedirectResponse code=303, streamlen=None>

Finally we verify that the trashed worksheet is gone:

sage: n.worksheet_names()
[]
sage: n.delete()
class sagenb.notebook.twist.FailedToplevel(info, problem, username=None)

Bases: sagenb.notebook.twist.Toplevel

render(ctx)
class sagenb.notebook.twist.ForgotPassPage

Bases: twisted.web2.resource.Resource

render(request)
sagenb.notebook.twist.HTMLResponse(*args, **kwds)

Returns an HTMLResponse object whose ‘Content-Type’ header has been set to text/html; charset=utf-8

EXAMPLES:

sage: from sagenb.notebook.twist import HTMLResponse
sage: response = HTMLResponse(stream='<html><head><title>Test</title></head><body>Test</body></html>')
sage: response.headers
<Headers: Raw: {'content-type': ['text/html; charset=utf-8']} Parsed: {'content-type': <RecalcNeeded>}>
class sagenb.notebook.twist.Help(username)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.History(username)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Images

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.InvalidPage(msg, username, cont='/', **kwargs)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.JSMath_js

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Java

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.Javascript

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.Keyboard_js

Bases: twisted.web2.resource.Resource

childFactory(request, browser_os)
class sagenb.notebook.twist.Keyboard_js_specific(browser_os)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.ListOfUsers(username)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.LiveHistory(username)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.LoginResourceClass

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.Logout

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.LogoutRedirectLogin

Bases: twisted.web2.resource.PostableResource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.Main_css

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Main_js

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.NewWorksheet(username)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.NotImplementedWorksheetOp(op, ws)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.NotebookSettingsPage(username)

Bases: twisted.web2.resource.PostableResource

render(request)
class sagenb.notebook.twist.PublicWorksheets(username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.PublishWorksheetRevision(worksheet, rev)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.RedirectLogin

Bases: twisted.web2.resource.PostableResource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.RedirectResponse(location)

Bases: twisted.web2.http.Response

A redirect response class that uses the proper status code (303 See Other) instead of 301 Moved Permanently, as twisted.web2 uses. This is not cached, unlike 301.

class sagenb.notebook.twist.RegConfirmation

Bases: twisted.web2.resource.Resource

render(request)
class sagenb.notebook.twist.RegistrationPage(userdb)

Bases: twisted.web2.resource.PostableResource

render(request)
class sagenb.notebook.twist.Response(code=None, headers=None, stream=None)

Bases: twisted.web2.http.Response

An adapter for twisted.web2.http.Response that automatically encodes its stream into UTF-8.

INPUT:

  • code – HTTP status code for the response
  • headers – headers to be sent
  • stream – content body to send
class sagenb.notebook.twist.RevertToWorksheetRevision(worksheet, rev)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.SageJavascript

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.SageTex(username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.SendWorksheetToActive(username)

Bases: sagenb.notebook.twist.SendWorksheetToFolder

action(W)
class sagenb.notebook.twist.SendWorksheetToArchive(username)

Bases: sagenb.notebook.twist.SendWorksheetToFolder

action(W)
class sagenb.notebook.twist.SendWorksheetToFolder(username)

Bases: twisted.web2.resource.PostableResource

action(W)
render(ctx)
class sagenb.notebook.twist.SendWorksheetToStop(username)

Bases: sagenb.notebook.twist.SendWorksheetToFolder

Quits each selected worksheet.

action(W)
class sagenb.notebook.twist.SendWorksheetToTrash(username)

Bases: sagenb.notebook.twist.SendWorksheetToFolder

action(W)
class sagenb.notebook.twist.SettingsPage(username)

Bases: twisted.web2.resource.PostableResource

render(request)
class sagenb.notebook.twist.Source(path, username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.SourceBrowser(username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.Toplevel(cookie, username)

Bases: twisted.web2.resource.PostableResource

childFactory(request, name)
render(ctx)
userchildFactory(request, name)
class sagenb.notebook.twist.TrivialResource

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Upload(username)

Bases: twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.UploadWorksheet(username)

Bases: twisted.web2.resource.PostableResource

render(ctx)
class sagenb.notebook.twist.UserToplevel(cookie, username)

Bases: sagenb.notebook.twist.Toplevel

render(request)
userchildFactory(request, name)
userchild_doc
alias of Doc
userchild_emptytrash
alias of EmptyTrash
userchild_help
alias of Help
userchild_history
alias of History
userchild_home
alias of Worksheets
userchild_live_history
alias of LiveHistory
userchild_new_worksheet
alias of NewWorksheet
userchild_pub
alias of PublicWorksheets
userchild_sagetex
alias of SageTex
userchild_send_to_active
alias of SendWorksheetToActive
userchild_send_to_archive
alias of SendWorksheetToArchive
userchild_send_to_stop
alias of SendWorksheetToStop
userchild_send_to_trash
alias of SendWorksheetToTrash
userchild_settings
alias of SettingsPage
userchild_src
alias of SourceBrowser
userchild_upload
alias of Upload
userchild_upload_worksheet
alias of UploadWorksheet
class sagenb.notebook.twist.Worksheet(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

childFactory(request, op)
render(ctx)
class sagenb.notebook.twist.WorksheetFile(path, username)

Bases: twisted.web2.resource.Resource

locateChild(request, segments)
render(ctx=None)
class sagenb.notebook.twist.WorksheetResource(name, username)
id(ctx)
class sagenb.notebook.twist.Worksheet_alive(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_cell_list(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Return the state number and the HTML for the main body of the worksheet, which consists of a list of cells.

render(ctx)
class sagenb.notebook.twist.Worksheet_cell_update(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

render(ctx)
class sagenb.notebook.twist.Worksheet_cells(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

childFactory(request, segment)
render(ctx)
class sagenb.notebook.twist.Worksheet_conf(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_copy(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

render(ctx)
class sagenb.notebook.twist.Worksheet_data(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.Worksheet_datafile(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_delete_all_output(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_delete_cell(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Deletes a notebook cell.

If there is only one cell left in a given worksheet, the request to delete that cell is ignored because there must be a least one cell at all times in a worksheet. (This requirement exists so other functions that evaluate relative to existing cells will still work, and so one can add new cells.)

render(ctx)
class sagenb.notebook.twist.Worksheet_delete_cell_output(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Deletes a cell’s output.

render(ctx)
class sagenb.notebook.twist.Worksheet_discard_and_quit(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Save a snapshot of a worksheet and quit.

render(ctx)
class sagenb.notebook.twist.Worksheet_do_upload_data(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

render(ctx)
class sagenb.notebook.twist.Worksheet_download(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

childFactory(request, tmp_title)
class sagenb.notebook.twist.Worksheet_edit(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

Return a window that allows the user to edit the text of the worksheet with the given filename.

render(ctx)
class sagenb.notebook.twist.Worksheet_edit_published_page(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_eval(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Evaluate a worksheet cell.

If the request is not authorized (the requester did not enter the correct password for the given worksheet), then the request to evaluate or introspect the cell is ignored.

If the cell contains either 1 or 2 question marks at the end (not on a comment line), then this is interpreted as a request for either introspection to the documentation of the function, or the documentation of the function and the source code of the function respectively.

render(ctx)
class sagenb.notebook.twist.Worksheet_hide_all(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_interrupt(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_introspect(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Cell introspection. This is called when the user presses the tab key in the browser in order to introspect.

render(ctx)
class sagenb.notebook.twist.Worksheet_invite_collab(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

render(ctx)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

class sagenb.notebook.twist.Worksheet_new_cell_after(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Adds a new cell after a given cell.

render(ctx)
class sagenb.notebook.twist.Worksheet_new_cell_before(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Adds a new cell before a given cell.

render(ctx)
class sagenb.notebook.twist.Worksheet_new_text_cell_after(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Adds a new text cell after a given cell.

render(ctx)
class sagenb.notebook.twist.Worksheet_new_text_cell_before(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Adds a new cell before a given cell.

render(ctx)
class sagenb.notebook.twist.Worksheet_pretty_print(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

childFactory(request, enable)
class sagenb.notebook.twist.Worksheet_print(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_publish(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

This is a child resource of the Worksheet resource. It provides a frontend to the management of worksheet publication. This management functionality includes initializational of publication, re-publication, automated publication when a worksheet saved, and ending of publication.

render(ctx)
class sagenb.notebook.twist.Worksheet_quit_sage(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_rate(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_rating_info(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_rename(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

render(ctx)
class sagenb.notebook.twist.Worksheet_restart_sage(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_revert_to_last_saved_state(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

render(ctx)
class sagenb.notebook.twist.Worksheet_revisions(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Show a list of revisions of this worksheet.

render(ctx)
class sagenb.notebook.twist.Worksheet_save(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Save the contents of a worksheet after editing it in plain-text edit mode.

render(ctx)
class sagenb.notebook.twist.Worksheet_save_and_close(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Save a snapshot of a worksheet then quit it.

render(ctx)
class sagenb.notebook.twist.Worksheet_save_and_quit(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Save a snapshot of a worksheet and quit.

render(ctx)
class sagenb.notebook.twist.Worksheet_save_snapshot(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Save a snapshot of a worksheet.

render(ctx)
class sagenb.notebook.twist.Worksheet_savedatafile(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

render(ctx)
class sagenb.notebook.twist.Worksheet_set_cell_output_type(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.PostableResource

Set the output type of the cell.

This enables the type of output cell, such as to allowing wrapping for output that is very long.

render(ctx)
class sagenb.notebook.twist.Worksheet_share(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_show_all(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheet_system(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

childFactory(request, system)
class sagenb.notebook.twist.Worksheet_text(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

Return a window that allows the user to edit the text of the worksheet with the given filename.

render(ctx)
class sagenb.notebook.twist.Worksheet_upload_data(name, username)

Bases: sagenb.notebook.twist.WorksheetResource, twisted.web2.resource.Resource

render(ctx)
class sagenb.notebook.twist.Worksheets(username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
class sagenb.notebook.twist.WorksheetsAdmin(username)

Bases: sagenb.notebook.twist.Worksheets

childFactory(request, name)
class sagenb.notebook.twist.WorksheetsByUser(user, username)

Bases: twisted.web2.resource.Resource

childFactory(request, name)
render(ctx)
render_list(ctx)
class sagenb.notebook.twist.WorksheetsByUserAdmin(user, username)

Bases: sagenb.notebook.twist.WorksheetsByUser

render(ctx)
sagenb.notebook.twist.do_passwords_match(pass1, pass2)

EXAMPLES:

sage: from sagenb.notebook.twist import do_passwords_match
sage: do_passwords_match('momcat', 'mothercat')
False
sage: do_passwords_match('mothercat', 'mothercat')
True
sagenb.notebook.twist.doc_worksheet()
sagenb.notebook.twist.encode_list(v)
sagenb.notebook.twist.extract_title(html_page)
sagenb.notebook.twist.gzip_handler(request)
Add gzip compression to the request if it makes sense.
sagenb.notebook.twist.init_updates()
sagenb.notebook.twist.is_valid_email(email)

Validates an email address. The implemention here is short, but it should cover the more common forms. In particular, it allows “plus addresses,” e.g.,

first.last+label@gmail.com

But it rejects several other classes, including those with comments, quoted local-parts, and/or IP address domains. For more information, please see RFC 3696, RFC 5322, and their errata.

INPUT:

  • email - string; the address to validate

OUTPUT:

  • a boolean; whether the address is valid, according to simplistic but widely used criteria

EXAMPLES:

sage: from sagenb.notebook.twist import is_valid_email
sage: is_valid_email('joe@washinton.gov')
True
sage: is_valid_email('joe.washington.gov')  # missing @
False
sage: is_valid_email('foo+plus@gmail.com')
True
sage: is_valid_email('foo++@gmail.com')
True
sage: is_valid_email('foo+bar+baz@gmail.com')
True
sage: is_valid_email('+plus@something.org')
True
sage: is_valid_email('hyphens-are-okay@example.ab.cd')
True
sage: is_valid_email('onlytld@com')         # missing subdomain
False
sage: is_valid_email("we..are@the.borg")    # consecutive dots not allowed
False
sage: is_valid_email("abcd@[12.34.56.78]")  # legal, really
False
sage: is_valid_email("x@y.z")               # legal but too short
False
sage: is_valid_email('"i c@nt"@do.it')      # legal, really
False
sage: is_valid_email(65 * 'a' + '@lim.sup') # username too long
False
sage: is_valid_email(32 * '@..@.][.' + '!') # too long, ...
False
sagenb.notebook.twist.is_valid_password(password, username)

Return True if and only if password is valid, i.e., is between 4 and 32 characters long, doesn’t contain space(s), and doesn’t contain username.

EXAMPLES:

sage: from sagenb.notebook.twist import is_valid_password
sage: is_valid_password('uip@un7!', None)
True
sage: is_valid_password('markusup89', None)
True
sage: is_valid_password('8u7', None)
False
sage: is_valid_password('fUmDagaz8LmtonAowjSe0Pvu9C5Gvr6eKcC6wsAT', None)
False
sage: is_valid_password('rrcF !u78!', None)
False
sage: is_valid_password('markusup89', 'markus')
False
sagenb.notebook.twist.is_valid_username(username)

Returns whether a candidate username is valid. It must contain between 3 and 65 of these characters: letters, numbers, underscores, @, and/or dots (‘.’).

INPUT:

  • username - a string; the candidate username

OUTPUT:

  • a boolean

EXAMPLES:

sage: from sagenb.notebook.twist import is_valid_username
sage: is_valid_username('mark10')
True
sage: is_valid_username('10mark')
False
sage: is_valid_username('me')
False
sage: is_valid_username('abcde' * 13)
False
sage: is_valid_username('David Andrews')
False
sage: is_valid_username('David M. Andrews')
False
sage: is_valid_username('sarah_andrews')
True
sage: is_valid_username('TA-1')
False
sage: is_valid_username('math125-TA')
False
sage: is_valid_username('dandrews@sagemath.org')
True
sagenb.notebook.twist.message(msg, cont='/', username=None, **kwargs)
sagenb.notebook.twist.notebook_idle_check()
sagenb.notebook.twist.notebook_save_check()
sagenb.notebook.twist.notebook_updates()
sagenb.notebook.twist.redirect(url)
sagenb.notebook.twist.render_worksheet_list(args, pub, username)

Returns a rendered worksheet listing.

INPUT:

  • args - ctx.args where ctx is the dict passed into a resource’s render method
  • pub - boolean, True if this is a listing of public worksheets
  • username - the user whose worksheets we are listing

OUTPUT:

a string

sagenb.notebook.twist.user_type(username)
sagenb.notebook.twist.word_wrap_cols()
sagenb.notebook.twist.worksheet_revision_publish(worksheet, rev, username)
sagenb.notebook.twist.worksheet_revision_revert(worksheet, rev, username)

Previous topic

HTML Templating for the Notebook

Next topic

Simple Sage Server API

This Page