Ask Your Question
1

add users to notebook from sage commandline

asked 2012-10-17 13:22:02 +0200

mhampton gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-10-18 09:11:15 +0200

Dirk Danckaert gravatar image

updated 2012-10-18 09:11:39 +0200

I'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.

edit flag offensive delete link more

Comments

I 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.

mhampton gravatar imagemhampton ( 2012-10-19 00:36:22 +0200 )edit

I tried that from scratch (starting over and inserting the "nbu.set_accounts(True)", and it still doesn't work.

mhampton gravatar imagemhampton ( 2012-10-19 00:48:59 +0200 )edit

I 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'.

Dirk Danckaert gravatar imageDirk Danckaert ( 2012-10-19 17:50:44 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-10-17 13:22:02 +0200

Seen: 861 times

Last updated: Oct 18 '12