Skip to content

Commit

Permalink
Minor changes to handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisonbg authored and minrk committed Oct 19, 2011
1 parent 29cdf0f commit e3e41dc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions IPython/frontend/html/notebook/handlers.py
Expand Up @@ -41,8 +41,10 @@

class AuthenticatedHandler(web.RequestHandler):
"""A RequestHandler with an authenticated user."""

def get_current_user(self):
user_id = self.get_secure_cookie("user")
# For now the user_id should not return empty, but it could eventually
if user_id == '':
user_id = 'anonymous'
if user_id is None:
Expand All @@ -54,17 +56,19 @@ def get_current_user(self):


class NBBrowserHandler(AuthenticatedHandler):

@web.authenticated
def get(self):
nbm = self.application.notebook_manager
project = nbm.notebook_dir
self.render('nbbrowser.html', project=project,
base_project_url=u'/', base_kernel_url=u'/')


class LoginHandler(AuthenticatedHandler):

def get(self):
user_id = self.get_secure_cookie("user") or ''
self.render('login.html', user_id=user_id)
self.render('login.html')

def post(self):
pwd = self.get_argument("password", default=u'')
Expand All @@ -73,7 +77,9 @@ def post(self):
url = self.get_argument("next", default="/")
self.redirect(url)


class NewHandler(AuthenticatedHandler):

@web.authenticated
def get(self):
notebook_id = self.application.notebook_manager.new_notebook()
Expand All @@ -82,6 +88,7 @@ def get(self):


class NamedNotebookHandler(AuthenticatedHandler):

@web.authenticated
def get(self, notebook_id):
nbm = self.application.notebook_manager
Expand Down

0 comments on commit e3e41dc

Please sign in to comment.