Skip to content

Commit

Permalink
Make the readonly file just have usernames, not messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Grout committed Jun 17, 2012
1 parent 62c3f9f commit 1048e15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions sagenb/notebook/notebook.py
Expand Up @@ -303,8 +303,7 @@ def readonly_user(self, username):
"""
Returns True if the user is supposed to only be a read-only user.
"""
readonly, message = self.__storage.readonly_user(username)
return readonly
return self.__storage.readonly_user(username)

##########################################################
# Publishing worksheets
Expand Down
9 changes: 3 additions & 6 deletions sagenb/storage/filesystem_storage.py
Expand Up @@ -611,20 +611,17 @@ def worksheets(self, username):

def readonly_user(self, username):
"""
Each line of the readonly file has format ``username:message``, where message could just be blank. The colon is important.
Each line of the readonly file has a username.
"""
filename = os.path.join(self._path, self._readonly_filename)
if not os.path.exists(filename):
return False, ''
mtime = os.path.getmtime(filename)
if mtime > self._readonly_mtime:
with open(filename) as f:
self._readonly = dict(line[:-1].split(':',1) for line in f)
self._readonly = set(line[:-1] for line in f if len(line[:-1])>0)
self._readonly_mtime = mtime
if username in self._readonly:
return True, self._readonly[username]
else:
return False, ''
return username in self._readonly

def delete(self):
"""
Expand Down

0 comments on commit 1048e15

Please sign in to comment.