On 3/26/11 10:03 AM, Jonathan wrote:
This problem with Jmol appears to be multifaceted.
1) The path to Jmol looks strange, although the error messages do
appear to come from Jmol.
2) It looks like something is being added to the top of the script
file for Jmol and confusing it.
3) Could also related to the JavaVM you are using. Jmol is only
tested against the Sun/Oracle VM.
*We are working on patches to Jmol in the present notebook. There are
still some asychronicity issues that I think I've almost got a handle
on. Let's not try to move this stuff to the new notebook until that
is solved. I hope today :)
I already applied all of your patches to my local copy of the flask
notebook, and I think everything is probably good to go except for the
problem I outline below.
Short version: when jmol requests a file, flask doesn't think the
request comes from an authenticated user, so it redirects jmol to the
notebook homepage so that jmol can log in. I think jmol should pass the
session cookie with its request to let flask know that the request is
coming from an authenticated user.
Long version:
I applied the following patch to devel/sagenb/flask_version/base.py:
diff -r 91e83c46bae5 flask_version/base.py
--- a/flask_version/base.py Wed Mar 16 03:40:25 2011 -0700
+++ b/flask_version/base.py Sat Mar 26 18:59:17 2011 -0500
@@ -23,6 +23,9 @@
self.add_static_path('/javascript', DATA)
self.add_static_path('/static', DATA)
self.add_static_path('/java', DATA)
+ import mimetypes
+ mimetypes.add_type('text/plain','.jmol')
+
#######
# Doc #
@@ -267,6 +270,8 @@
@app.before_request
def set_notebook_object():
g.notebook = notebook
+ if not request.path.endswith('alive'):
+ print "REQUEST: ", request
########################
# Register the modules #
The first hunk (from Ira Hanson) ensures that ".jmol" files are
delivered as text (otherwise, it seems that they are delivered as binary
something-or-other). The second hunk prints out every request that is
made of the server. Then I opened a new worksheet and tried to create a
jmol plot. Here is the relevant logging info:
REQUEST: <Request 'http://localhost:8000/home/admin/309/JmolApplet' [GET]>
REQUEST: <Request
'http://localhost:8000/home/admin/309/cells/1/sage0-size500.jmol?1301173518'
[GET]>
REQUEST: <Request
'http://localhost:8000/?next=http%3A%2F%2Flocalhost%3A8000%2Fhome%2Fadmin%2F309%2Fcells%2F1%2Fsage0-size500.jmol%3F1301173518'
[GET]>
Notice that jmol tries to get the .jmol file. However, it is redirected
to the root with a next query parameter. This indicates to me that
flask did not think that jmol had permissions to get the file, and
redirected jmol to the root so it could log in. So I think the key
problem here is that when jmol tries to request the .jmol file, it isn't
giving the necessary cookies or whatever to let flask know that it is
part of the current session.
So how do we solve this? How does flask know that jmol's request is
part of the current logged-in session? If jmol passed the right cookie,
I think that would do it. We could also just turn off authentication
checks for retrieving files from cells, though that sounds risky. I
think that would be what was done with the old notebook, though.
Another thing we could do is pass a secret key to jmol which would
enable it to retrieve the file, even if it didn't send the session
cookie back to flask with its request for the file.
Rado or Mike: how do you think we should get jmol requests to be
recognized as requests coming from an authenticated user?
Jonathan: do you know any other places where jmol is used behind a
login, so it has to request files and data with some sort of session
cookie or something?
Thanks,
Jason
--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org