#378: User-specified path for load and attach
------------------------------+---------------------------------------------
   Reporter:  was             |       Owner:  was       
       Type:  enhancement     |      Status:  needs_work
   Priority:  major           |   Milestone:  sage-4.6.1
  Component:  user interface  |    Keywords:            
     Author:  Mitesh Patel    |    Upstream:  N/A       
   Reviewer:                  |      Merged:            
Work_issues:                  |  
------------------------------+---------------------------------------------

Comment(by flawrence):

 Replying to [comment:10 timdumol]:
 > Things work perfectly, but I think it might be better to follow the
 Python stdlib in exposing the array itself, instead of covering it in a
 function (`sys.path` instead of `sys.path()`, so similarly,
 `load_attach_path` instead of `load_attach_path()`). Also, it might be
 handy to `os.path.expand_user` any paths handed to the function, so you
 could have load_attach_path.append("~/foo"). What do you think?

 I've had a bit of a hack at exposing the array itself, but there are
 problems making it sufficiently global.  `sys.path` works for the stdlib
 because `path` is a variable in the `sys` module.  The logical thing to do
 here is to create a `load_attach_path` variable in the preparser module,
 but following the stdlib analogy this would require the user to edit
 `sage.misc.preparser.load_attach_path`, which is not very user friendly.

 Failing this, it looks like the best you can do is a `from
 sage.misc.preparser import load_attach_path`, but this is a fragile state
 of affairs: if you reassign `load_attach_path` anywhere, either from
 sage's command line or by calling some function like
 `sage.misc.preparser.reset_load_attach_path()`, you end up with a
 situation where `load_attach_path` and
 `sage.misc.preparser.load_attach_path` are different objects.

 This requires caution on the part of the user and the programmer.  For
 example, `reset_load_attach_path()` can't include
 {{{
 load_attach_path = ['.']
 }}}

 instead it has to do
 {{{
 while load_attach_path != []:
     load_attach_path.pop()
 load_attach_path.append('.')
 }}}

 If the user accidentally reassigns `load_attach_path` in the command line,
 they'll have to re-run `from sage.misc.preparser import load_attach_path`.
 I don't think that this step can be included in a
 `reset_load_attach_path()` function due to the different scopes.

 So it's possible to expose the `load_attach_path` array to the user, and
 I've written most of a patch that does this, but there's lots of things
 that could go wrong so I'd suggest sticking to the existing patch's
 approach of hiding behind a function.  If others think that the pros
 outweigh the cons then I'll tidy up the patch and upload it.

 Thoughts?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/378#comment:16>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to