# HG changeset patch
# User Timothy Clemans <timothy.clemans@gmail.com>
# Date 1213865708 25200
# Node ID 20f6ac19586e794e0f1031bc8518e5702612a670
# Parent  8b373ea0f9360e34dae09a1370955e2ea7717a4d
#3463

diff -r 8b373ea0f936 -r 20f6ac19586e sage/server/notebook/avatars.py
--- a/sage/server/notebook/avatars.py	Wed Jun 18 13:42:58 2008 -0700
+++ b/sage/server/notebook/avatars.py	Thu Jun 19 01:55:08 2008 -0700
@@ -18,6 +18,8 @@ from twisted.web2 import iweb
 from twisted.web2 import iweb
 from twisted.python import log
 import resources.toplevels as toplevels
+
+notebook = None
 
 def user_type(avatarId):
     if isinstance(avatarId, FailedLogin):
@@ -129,7 +131,7 @@ class LoginSystem(object):
                 return (iweb.IResource, rsrc, self.logout)
             
             if avatarId is checkers.ANONYMOUS: #anonymous user
-                rsrc = toplevels.AnonymousToplevel(self.cookie, avatarId)
+                rsrc = toplevels.AnonymousToplevel(self.cookie, avatarId, notebook=notebook)
                 return (iweb.IResource, rsrc, self.logout)
 
             elif user_type(avatarId) == 'invalid_user':
diff -r 8b373ea0f936 -r 20f6ac19586e sage/server/notebook/resources/toplevels.py
--- a/sage/server/notebook/resources/toplevels.py	Wed Jun 18 13:42:58 2008 -0700
+++ b/sage/server/notebook/resources/toplevels.py	Thu Jun 19 01:55:08 2008 -0700
@@ -1,11 +1,16 @@ import sage.server.notebook
 import sage.server.notebook
 import sage.server.notebook.twist as twist
-import sage.server.notebook.avatars as avatars
+#import sage.server.notebook.avatars as avatars
 from sage.server.notebook.template import login_page_template
+from twisted.web2 import http
 
 class AnonymousToplevel(twist.Toplevel):
+    def __init__(self, cookie, username, notebook=None):
+        self.notebook = notebook
+        twist.Toplevel.__init__(self, cookie, username)
+        
     addSlash = True
-    child_register = twist.RegistrationPage(avatars.PasswordChecker())
+    #child_register = twist.RegistrationPage(avatars.PasswordChecker())
     child_confirm = twist.RegConfirmation()
     child_forgotpass = twist.ForgotPassPage()
 
@@ -29,5 +34,5 @@ class AnonymousToplevel(twist.Toplevel):
     #child_login = LoginResource
     
     def render(self, ctx):
-        return http.Response(stream =  login_page_template(notebook.get_accounts(), notebook.default_user()))
+        return http.Response(stream =  login_page_template(self.notebook.get_accounts(), self.notebook.default_user()))
 
diff -r 8b373ea0f936 -r 20f6ac19586e sage/server/notebook/run_notebook.py
--- a/sage/server/notebook/run_notebook.py	Wed Jun 18 13:42:58 2008 -0700
+++ b/sage/server/notebook/run_notebook.py	Thu Jun 19 01:55:08 2008 -0700
@@ -208,6 +208,7 @@ from twisted.cred import portal, checker
 from twisted.cred import portal, checkers, credentials
 import sage.server.notebook.guard as guard
 import sage.server.notebook.avatars as avatars
+avatars.notebook = notebook.load_notebook(%s)
 
 from twisted.cred import portal
 
@@ -235,7 +236,7 @@ reactor.addSystemEventTrigger('before', 
 reactor.addSystemEventTrigger('before', 'shutdown', save_notebook)
 
 """%(notebook_opts, sagetex_path, not require_login,
-     os.path.abspath(directory), strport, open_page))
+     os.path.abspath(directory), notebook_opts, strport, open_page))
 
 
         config.close()                     
