Ask Your Question
1

add users to notebook from sage commandline

asked 12 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 12 years ago

Dirk Danckaert gravatar image

updated 12 years ago

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.

Preview: (hide)
link

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 ( 12 years ago )

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

mhampton gravatar imagemhampton ( 12 years ago )

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 ( 12 years ago )

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: 12 years ago

Seen: 963 times

Last updated: Oct 18 '12