accessing worksheet's username and/or choosing user-specific folders

49 views
Skip to first unread message

rych

unread,
Nov 7, 2012, 3:12:08 PM11/7/12
to sage-n...@googlegroups.com
What is the best way to have a more or less persistent folder for each notebook user (not 'sageslave' or 'sageservice') and how to access the current worksheet owner's user name and/or the user-specific folder from within the worksheet? Otherwise users running copies of my published worksheets overwrite my calculations saving to the same folder.
Thanks,
Igor

Jason Grout

unread,
Nov 7, 2012, 3:14:29 PM11/7/12
to sage-n...@googlegroups.com
Can you give an example of a public worksheet that has this problem? By
default, all user data is already stored in separate folders, one per
user. Users running copies of your public worksheets will not overwrite
your calculations. Their copies of your public worksheets are totally
separate (in their own folders) from your public worksheet.

Thanks,

Jason

rych

unread,
Nov 7, 2012, 3:43:02 PM11/7/12
to sage-n...@googlegroups.com
Thanks Jason,
On our installation I can use the folder named '/home/sageservice/tmp/' to save my data to from one worksheet and access it from another or a different program. Is there a better path that is permanent, user-specific, is readable by other programs, and has a nice natural name, e.g, /home/sageservice/tmp/<username>? If not I'll make one within each worksheet, but then I need to know that <username>.
Igor

Jason Grout

unread,
Nov 7, 2012, 5:25:46 PM11/7/12
to sage-n...@googlegroups.com
On 11/7/12 2:43 PM, rych wrote:
> Thanks Jason,
> On our installation I can use the folder named '/home/sageservice/tmp/'
> to save my data to from one worksheet and access it from another or a
> different program. Is there a better path that is
> permanent, user-specific, is readable by other programs, and has a nice
> natural name, e.g, /home/sageservice/tmp/<username>? If not I'll make
> one within each worksheet, but then I need to know that <username>.
> Igor

Okay, that makes sense. I don't know of a natural way to have a
per-user directory that exists outside of the notebook. I don't know of
a good way to get the user name from within code running in the
worksheet. However, here's a bad way (i.e., a way that might break
unpredictably in the future if we change implementations): parse the
username out of the DATA string inside the notebook. Then create
directories like you mention above.

Thanks,

Jason

rych

unread,
Nov 8, 2012, 2:25:27 AM11/8/12
to sage-n...@googlegroups.com
Good. I'll do it like this
DATA.split('/home/sageservice/nbfiles.sagenb/home/')[1].split('/',1)[0]
until I find a cleverer way of string parsing.
Thanks,
Igor
Reply all
Reply to author
Forward
0 new messages