ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 19 Oct 2012 10:50:44 -0500add users to notebook from sage commandlinehttp://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/I know I've done this before, but it was a few years ago and I can't remember exactly how I did it. Its possible that the notebook has changed in some relevant ways in the meantime.
I'd like to add a bunch of users to a notebook from the commandline. I tried something like this:
users = [['Alice','123'], ['Bob','123'], ['Carol','789']]
nb = sagenb.notebook.notebook.load_notebook('/path/to/my.sagenb/')
nbu = nb.user_manager()
for u in users:
nbu.add_user(u[0],u[1],'',account_type='user',force=True)
nb.save()
But the users do not show up when I start the notebook.Wed, 17 Oct 2012 06:22:02 -0500http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/Answer by Dirk Danckaert for <p>I know I've done this before, but it was a few years ago and I can't remember exactly how I did it. Its possible that the notebook has changed in some relevant ways in the meantime.</p>
<p>I'd like to add a bunch of users to a notebook from the commandline. I tried something like this:</p>
<pre><code>users = [['Alice','123'], ['Bob','123'], ['Carol','789']]
nb = sagenb.notebook.notebook.load_notebook('/path/to/my.sagenb/')
nbu = nb.user_manager()
for u in users:
nbu.add_user(u[0],u[1],'',account_type='user',force=True)
nb.save()
</code></pre>
<p>But the users do not show up when I start the notebook.</p>
http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?answer=14161#post-id-14161I've been puzzling about exactly the same thing yesterday. You only have to add the line
nbu.set_accounts(True)
to your script (before you start adding users). It's clearly indicated in the reference manual, but I overlooked it too.Thu, 18 Oct 2012 02:11:15 -0500http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?answer=14161#post-id-14161Comment by mhampton for <p>I've been puzzling about exactly the same thing yesterday. You only have to add the line</p>
<pre><code>nbu.set_accounts(True)
</code></pre>
<p>to your script (before you start adding users). It's clearly indicated in the reference manual, but I overlooked it too.</p>
http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?comment=18847#post-id-18847I thought I tried that, and it didn't work. But I will try again, perhaps things get messed up if it is not done initially.Thu, 18 Oct 2012 17:36:22 -0500http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?comment=18847#post-id-18847Comment by Dirk Danckaert for <p>I've been puzzling about exactly the same thing yesterday. You only have to add the line</p>
<pre><code>nbu.set_accounts(True)
</code></pre>
<p>to your script (before you start adding users). It's clearly indicated in the reference manual, but I overlooked it too.</p>
http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?comment=18842#post-id-18842I did essentially the same thing as you did, and it worked for me. So I'm only guessing now what else could have gone wrong.
* interactively adding users only works for usernames with at least 4 characters. Mayb 'Bob' is messing things up?
* I mistyped my path to the notebook. Then Sage produced a whole new notebook in the path I specified. But running the notebook took me right back to the notebook on the standard location.
* I don't think mailaddresses are mandatory, but I provided them, and I see you didn't.
Btw: I just noticed the path to your notebook ends in a '/'. If you did this in your script, then SAGE would have created a (hidden) .sagenb folder in that directory. Maybe you have to check this with 'ls -a'.Fri, 19 Oct 2012 10:50:44 -0500http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?comment=18842#post-id-18842Comment by mhampton for <p>I've been puzzling about exactly the same thing yesterday. You only have to add the line</p>
<pre><code>nbu.set_accounts(True)
</code></pre>
<p>to your script (before you start adding users). It's clearly indicated in the reference manual, but I overlooked it too.</p>
http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?comment=18846#post-id-18846I tried that from scratch (starting over and inserting the "nbu.set_accounts(True)", and it still doesn't work.Thu, 18 Oct 2012 17:48:59 -0500http://ask.sagemath.org/question/9441/add-users-to-notebook-from-sage-commandline/?comment=18846#post-id-18846