ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 09 Apr 2011 20:38:02 +0200Changing the name of a notebook userhttps://ask.sagemath.org/question/8065/changing-the-name-of-a-notebook-user/I'd like to change the name of a user on my server. An alternative would be to delete the user and add them again with the new name. I can't figure out how to do this. The "User Management" interface in the notebook itself has an "Add User" but not a "Del User." In the reference manual I can see that there is a del_user() function for a notebook. But, the part I'm stuck on is:
nb = load_notebook(dir)
I can't figure out what "dir" is. In other words, I don't know how to find out what that directory is. This is a server that I normally start up by doing the notebook() call (that is, I haven't done anything to put it in any particular directory).
This is: Sage Version 4.6
Sat, 09 Apr 2011 14:33:57 +0200https://ask.sagemath.org/question/8065/changing-the-name-of-a-notebook-user/Answer by Kelvin Li for <p>I'd like to change the name of a user on my server. An alternative would be to delete the user and add them again with the new name. I can't figure out how to do this. The "User Management" interface in the notebook itself has an "Add User" but not a "Del User." In the reference manual I can see that there is a del_user() function for a notebook. But, the part I'm stuck on is:</p>
<p>nb = load_notebook(dir)</p>
<p>I can't figure out what "dir" is. In other words, I don't know how to find out what that directory is. This is a server that I normally start up by doing the notebook() call (that is, I haven't done anything to put it in any particular directory).</p>
<p>This is: Sage Version 4.6</p>
https://ask.sagemath.org/question/8065/changing-the-name-of-a-notebook-user/?answer=12281#post-id-12281I don't know about re-naming users, but here are all the steps you need to delete a user (adding one is easy enough):
1) Find your notebook directory. The default is `$HOME/.sage/sage_notebook.sagenb` (on Linux at least). If unsure, start your notebook server. On my machine, there is a line printed that says:
The notebook files are stored in: sage_notebook.sagenb
2) On my machine, this is what I did to delete a user:
sage: nb = sagenb.notebook.notebook.load_notebook("/home/goofy/.sage/sage_notebook.sagenb")
sage: nb.users()
{'admin': admin, 'user2': user2, 'user1': user1}
sage: nb.del_user("user2")
sage: nb.users()
{'admin': admin, 'user1': user1}
sage: nb.save()
3) Remarks
a) In the above example, nothing is done to the actual notebook files until the final step.
b) The function `sagenb.notebook.notebook.load_notebook(dir)` requires `dir` NOT to have a trailing "`/`" to work properly. So, if you use tab-completion (very handy!), be sure to remove that trailing slash. Otherwise, `load_notebook` would create a new notebook directory (`.sagenb`) within `dir` instead of simply opening `dir` itself as a notebook.Sat, 09 Apr 2011 20:11:25 +0200https://ask.sagemath.org/question/8065/changing-the-name-of-a-notebook-user/?answer=12281#post-id-12281Comment by Mike Witt for <p>I don't know about re-naming users, but here are all the steps you need to delete a user (adding one is easy enough):</p>
<p>1) Find your notebook directory. The default is <code>$HOME/.sage/sage_notebook.sagenb</code> (on Linux at least). If unsure, start your notebook server. On my machine, there is a line printed that says:</p>
<pre><code>The notebook files are stored in: sage_notebook.sagenb
</code></pre>
<p>2) On my machine, this is what I did to delete a user:</p>
<pre><code>sage: nb = sagenb.notebook.notebook.load_notebook("/home/goofy/.sage/sage_notebook.sagenb")
sage: nb.users()
{'admin': admin, 'user2': user2, 'user1': user1}
sage: nb.del_user("user2")
sage: nb.users()
{'admin': admin, 'user1': user1}
sage: nb.save()
</code></pre>
<p>3) Remarks</p>
<p>a) In the above example, nothing is done to the actual notebook files until the final step.</p>
<p>b) The function <code>sagenb.notebook.notebook.load_notebook(dir)</code> requires <code>dir</code> NOT to have a trailing "<code>/</code>" to work properly. So, if you use tab-completion (very handy!), be sure to remove that trailing slash. Otherwise, <code>load_notebook</code> would create a new notebook directory (<code>.sagenb</code>) within <code>dir</code> instead of simply opening <code>dir</code> itself as a notebook.</p>
https://ask.sagemath.org/question/8065/changing-the-name-of-a-notebook-user/?comment=21881#post-id-21881Thank you. It was the $HOME/.sage/sage_notebook.sagenb that I couldn't figure out.Sat, 09 Apr 2011 20:38:02 +0200https://ask.sagemath.org/question/8065/changing-the-name-of-a-notebook-user/?comment=21881#post-id-21881