On Tuesday, July 8, 2014 11:53:33 AM UTC-7, Jole Bradbury wrote:
>
> I have a Django project with 
> views.py:
>
> #!/usr/bin/env sage -python
>
> from django.shortcuts import render
> from django.http import HttpResponse
> import sys
> from django.http import HttpRequest
> from django.template import RequestContext, loaders
> sys.path.append('/Users/Jole/Desktop/django_proj/mysite/sage/src/bin')
> sys.path.append('/Users/Jole/Desktop/django_proj/mysite/sage/')
> from sage.all import *
>
 
Unfortunately, when I fire up my Django server on localhost, I get: No 
module named sage.all

As an error message. As you can see I have already tried appending to the 
path. My Python Path includes sage and I can see this on my Django page, 
however my "PATH" is 
PATH

'/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin'



That's not the path that `sage -python` would set up, so my guess is that 
`views.py` doesn't actually get *executed* (and hence run in a way 
equivalent to `sage -python views.py`), but instead gets loaded/interpreted 
by whatever python is running django. You should probably try and execute

sage -python -c 'import django.shortcuts'

my guess is that that would fail, proving that you didn't install django in 
sage's python and hence prove that your script isn't being executed by 
sage's python, since that line seems to execute properly in your situation.

If you want to use both django and sage in the same python, you have to 
ensure that both are available to the same python. The easier way to 
accomplish that is probably to install django in sage's python, since sage 
has its own python for a reason. I have no experience with django, nor a 
clear idea what it does, so I have no idea whether it's a good/feasible 
plan to mix the two. If django is a web-server, then you should probably 
tread very carefully. Math software and web services mix badly, because 
math software is usually written with no concern for security (it's written 
for a situation where one trusts the user), but for web software security 
is vital.

Things like sagecell and MathCloud put a *lot* of work in mitigating the 
security holes that are virtually unavoidable in making large parts of math 
software available via web services.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to