3.4 The Sage Notebook Twisted Web Server

Module: sage.server.notebook.twist

The Sage Notebook Twisted Web Server

Module-level Functions

do_passwords_match( pass1, pass2)

sage: from sage.server.notebook.twist import do_passwords_match
sage: do_passwords_match('momcat', 'mothercat')
False
sage: do_passwords_match('mothercat', 'mothercat')
True

doc_worksheet( )

encode_list( v)

extract_title( html_page)

init_updates( )

is_valid_email( email)

from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65215

sage: from sage.server.notebook.twist import is_valid_email
sage: is_valid_email('joe@washinton.gov')
True
sage: is_valid_email('joe.washington.gov')
False

is_valid_password( password, username)

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

sage: from sage.server.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

is_valid_username( username)

Returns True if and only if username is valid, i.e., starts with a letter, is between 4 and 32 characters long, and contains only letters, numbers, underscores, and and one dot (.).

sage: from sage.server.notebook.twist import is_valid_username

username must start with a letter

sage: is_valid_username('mark10')
True
sage: is_valid_username('10mark')
False

username must be between 4 and 32 characters long

sage: is_valid_username('bob') 
False
sage: is_valid_username('I_love_computer_science_and_maths') #33 characters long
False

username must not have more than one dot (.)

sage: is_valid_username('david.andrews')
True
sage: is_valid_username('david.m.andrews')
False
sage: is_valid_username('math125.TA.5')
False

username must not have any spaces

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')
False

message( msg, [cont=None])

notebook_idle_check( )

notebook_save_check( )

notebook_updates( )

redirect( url)

render_worksheet_list( args, pub, username)

set_cookie( cookie)

user_type( username)

word_wrap_cols( )

worksheet_revision_publish( worksheet, rev, username)

worksheet_revision_revert( worksheet, rev, username)

Class: AddWorksheet

class AddWorksheet

Functions: render

Class: AdminToplevel

class AdminToplevel

Functions: render

Class: AnonymousToplevel

class AnonymousToplevel

Functions: render,$ \,$ userchildFactory

Class: CellData

class CellData
CellData( self, worksheet, number)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: CSS

class CSS

Functions: childFactory,$ \,$ render

Class: Doc

class Doc
Doc( self, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: DocLive

class DocLive
DocLive( self, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: DocStatic

class DocStatic

Functions: childFactory,$ \,$ render

Class: EmptyTrash

class EmptyTrash
EmptyTrash( self, username)

This twisted resource empties the trash of the current user when it is rendered.

We create an instance of this resource.

sage: E = sage.server.notebook.twist.EmptyTrash('sage'); E
<sage.server.notebook.twist.EmptyTrash object at ...>

Functions: render

render( self, ctx)

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

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

sage: n = sage.server.notebook.notebook.Notebook('notebook-test')
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: sage.server.notebook.twist.notebook = n
sage: E = sage.server.notebook.twist.EmptyTrash('sage'); E
<sage.server.notebook.twist.EmptyTrash object at ...>
sage: E.render(None)
<twisted.web2.http.Response code=200, streamlen=603>

Finally we verify that the trashed worksheet is gone:

sage: n.worksheet_names()
[]
sage: n.delete()

Special Functions: __init__

Class: FailedToplevel

class FailedToplevel
FailedToplevel( self, info, problem, [username=None])

Functions: render

Special Functions: __init__

Class: ForgotPassPage

class ForgotPassPage

Functions: render

Class: Help

class Help
Help( self, username)

Functions: render

Special Functions: __init__

Class: History

class History
History( self, username)

Functions: render

Special Functions: __init__

Class: Images

class Images

Functions: childFactory,$ \,$ render

Class: InvalidPage

class InvalidPage
InvalidPage( self, msg, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: Java

class Java

Functions: childFactory,$ \,$ render

Class: Javascript

class Javascript

Functions: childFactory,$ \,$ render

Class: Keyboard_js

class Keyboard_js

Functions: childFactory

Class: Keyboard_js_specific

class Keyboard_js_specific
Keyboard_js_specific( self, browser_os)

Functions: render

Special Functions: __init__

Class: LiveHistory

class LiveHistory
LiveHistory( self, username)

Functions: render

Special Functions: __init__

Class: LoginResourceClass

class LoginResourceClass

Functions: childFactory,$ \,$ render

Class: Logout

class Logout

Functions: render

Class: Main_css

class Main_css

Functions: render

Class: Main_js

class Main_js

Functions: render

Class: NewWorksheet

class NewWorksheet
NewWorksheet( self, username)

Functions: render

Special Functions: __init__

Class: NotebookConf

class NotebookConf

Functions: render

Class: NotebookSettings

class NotebookSettings
NotebookSettings( self, username)

Functions: render

Special Functions: __init__

Class: NotImplementedWorksheetOp

class NotImplementedWorksheetOp
NotImplementedWorksheetOp( self, op, ws)

Functions: render

Special Functions: __init__

Class: ProcessNotebookSettings

class ProcessNotebookSettings

Functions: render

Class: ProcessUserSettings

class ProcessUserSettings

Functions: render

Class: PublicWorksheets

class PublicWorksheets
PublicWorksheets( self, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: PublicWorksheetsHome

class PublicWorksheetsHome
PublicWorksheetsHome( self, username)

Functions: childFactor

Special Functions: __init__

Class: PublishWorksheetRevision

class PublishWorksheetRevision
PublishWorksheetRevision( self, worksheet, rev)

Functions: render

Special Functions: __init__

Class: RedirectLogin

class RedirectLogin

Functions: childFactory,$ \,$ render

Class: RegConfirmation

class RegConfirmation

Functions: render

Class: RegistrationPage

class RegistrationPage
RegistrationPage( self, userdb)

Functions: render

Special Functions: __init__

Class: Reset_css

class Reset_css

Functions: render

Class: RevertToWorksheetRevision

class RevertToWorksheetRevision
RevertToWorksheetRevision( self, worksheet, rev)

Functions: render

Special Functions: __init__

Class: SageTex

class SageTex
SageTex( self, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: SendWorksheetToActive

class SendWorksheetToActive

Functions: action

Class: SendWorksheetToArchive

class SendWorksheetToArchive

Functions: action

Class: SendWorksheetToFolder

class SendWorksheetToFolder
SendWorksheetToFolder( self, username)

Functions: action,$ \,$ render

Special Functions: __init__

Class: SendWorksheetToStop

class SendWorksheetToStop
Saves and quits each selected worksheet.

Functions: action

Class: SendWorksheetToTrash

class SendWorksheetToTrash

Functions: action

Class: SettingsPage

class SettingsPage
SettingsPage( self, username)

Functions: render

Special Functions: __init__

Class: Slider

class Slider

Functions: childFactory,$ \,$ render

Class: Source

class Source
Source( self, path, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: SourceBrowser

class SourceBrowser
SourceBrowser( self, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: Toplevel

class Toplevel
Toplevel( self, cookie, username)

Functions: childFactory,$ \,$ render,$ \,$ userchildFactory

Special Functions: __init__

Class: TrivialResource

class TrivialResource

Functions: render

Class: Upload

class Upload

Functions: render

Class: UploadWorksheet

class UploadWorksheet
UploadWorksheet( self, username)

Functions: render

Special Functions: __init__

Class: UserToplevel

class UserToplevel

Functions: render,$ \,$ userchildFactory

Class: Worksheet

class Worksheet

Functions: childFactory,$ \,$ render

Class: Worksheet_alive

class Worksheet_alive

Functions: render

Class: Worksheet_cell_update

class Worksheet_cell_update

Functions: render

Class: Worksheet_cells

class Worksheet_cells

Functions: childFactory,$ \,$ render

Class: Worksheet_conf

class Worksheet_conf

Functions: render

Class: Worksheet_copy

class Worksheet_copy

Functions: render

Class: Worksheet_data

class Worksheet_data

Functions: childFactory,$ \,$ render

Class: Worksheet_datafile

class Worksheet_datafile

Functions: render

Class: Worksheet_delete_all_output

class Worksheet_delete_all_output

Functions: render

Class: Worksheet_delete_cell

class Worksheet_delete_cell
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.)

Functions: render

Class: Worksheet_discard_and_quit

class Worksheet_discard_and_quit
Save a snapshot of a worksheet and quit.

Functions: render

Class: Worksheet_do_upload_data

class Worksheet_do_upload_data

Functions: render

Class: Worksheet_download

class Worksheet_download

Functions: childFactory

Class: Worksheet_edit

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

Functions: render

Class: Worksheet_edit_published_page

class Worksheet_edit_published_page

Functions: render

Class: Worksheet_eval

class Worksheet_eval
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.

Functions: render

Class: Worksheet_hide_all

class Worksheet_hide_all

Functions: render

Class: Worksheet_input_settings

class Worksheet_input_settings

Functions: render

Class: Worksheet_interrupt

class Worksheet_interrupt

Functions: render

Class: Worksheet_introspect

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

Functions: render

Class: Worksheet_invite_collab

class Worksheet_invite_collab

Functions: render

Class: Worksheet_link_datafile

class Worksheet_link_datafile

Functions: render

Class: Worksheet_new_cell_after

class Worksheet_new_cell_after
Adds a new cell after a given cell.

Functions: render

Class: Worksheet_new_cell_before

class Worksheet_new_cell_before
Adds a new cell before a given cell.

Functions: render

Class: Worksheet_plain

class Worksheet_plain

Functions: render

Class: Worksheet_pretty_print

class Worksheet_pretty_print

Functions: childFactory

Class: Worksheet_print

class Worksheet_print

Functions: render

Class: Worksheet_publish

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

Functions: render

Class: Worksheet_quit_sage

class Worksheet_quit_sage

Functions: render

Class: Worksheet_rate

class Worksheet_rate

Functions: render

Class: Worksheet_rating_info

class Worksheet_rating_info

Functions: render

Class: Worksheet_rename

class Worksheet_rename

Functions: render

Class: Worksheet_restart_sage

class Worksheet_restart_sage

Functions: render

Class: Worksheet_revert_to_last_saved_state

class Worksheet_revert_to_last_saved_state

Functions: render

Class: Worksheet_revisions

class Worksheet_revisions
Show a list of revisions of this worksheet.

Functions: render

Class: Worksheet_save

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

Functions: render

Class: Worksheet_save_and_close

class Worksheet_save_and_close
Save a snapshot of a worksheet then quit it.

Functions: render

Class: Worksheet_save_and_quit

class Worksheet_save_and_quit
Save a snapshot of a worksheet and quit.

Functions: render

Class: Worksheet_save_snapshot

class Worksheet_save_snapshot
Save a snapshot of a worksheet.

Functions: render

Class: Worksheet_savedatafile

class Worksheet_savedatafile

Functions: render

Class: Worksheet_set_cell_output_type

class Worksheet_set_cell_output_type
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.

Functions: render

Class: Worksheet_settings

class Worksheet_settings

Functions: render

Class: Worksheet_share

class Worksheet_share

Functions: render

Class: Worksheet_show_all

class Worksheet_show_all

Functions: render

Class: Worksheet_system

class Worksheet_system

Functions: childFactory

Class: Worksheet_text

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

Functions: render

Class: Worksheet_upload_data

class Worksheet_upload_data

Functions: render

Class: WorksheetFile

class WorksheetFile
WorksheetFile( self, path, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: WorksheetResource

class WorksheetResource
WorksheetResource( self, name, username)

Functions: id

Special Functions: __init__

Class: Worksheets

class Worksheets
Worksheets( self, username)

Functions: childFactory,$ \,$ render

Special Functions: __init__

Class: WorksheetsAdmin

class WorksheetsAdmin

Functions: childFactory

Class: WorksheetsByUser

class WorksheetsByUser
WorksheetsByUser( self, user, username)

Functions: childFactory,$ \,$ render,$ \,$ render_list

Special Functions: __init__

Class: WorksheetsByUserAdmin

class WorksheetsByUserAdmin

Functions: render

See About this document... for information on suggesting changes.