Opened 14 years ago

Closed 14 years ago

#2346 closed enhancement (fixed)

[with patch, positive review] Sage needs a simple api for interaction with other applications

Reported by: robertwb Owned by: robertwb
Priority: major Milestone: sage-3.0
Component: user interface Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Many people have shown interest in a simple API that could be used to interface with Sage. This would be useful for java applets, moodle plugins, and other applications to use Sage as a computational back end.

Attachments (4)

simple-api.hg (7.7 KB) - added by robertwb 14 years ago.
2346-loops.patch (5.8 KB) - added by robertwb 14 years ago.
2346-gnutls.patch (3.6 KB) - added by robertwb 14 years ago.
2346-early-ssl-import.patch (2.1 KB) - added by robertwb 14 years ago.

Download all attachments as: .zip

Change History (15)

Changed 14 years ago by robertwb

comment:1 Changed 14 years ago by robertwb

The above bundle implements a simple api over http as described in http://groups.google.com/group/sage-edu/browse_thread/thread/f2935bb4ddb72dc5

It should be completely useable in its current form, though of course there is lots of room for improvement.

comment:2 Changed 14 years ago by robertwb

  • Owner changed from was to robertwb
  • Status changed from new to assigned
  • Summary changed from Sage needs a simple api for interaction with other applications to [with patch] Sage needs a simple api for interaction with other applications

comment:3 Changed 14 years ago by mhansen

  • Summary changed from [with patch] Sage needs a simple api for interaction with other applications to [with patch, positive review pending changes] Sage needs a simple api for interaction with other applications

A few comments:

1) Other than an unknown parent message, this applies cleanly against 2.10.3.alpha0

2) I can't get the server/simple/twisted.py tests to pass. The following error causes all the problems:

 IOError: [Errno url error] unknown url type: 'https'

Other than that, this patch looks excellent!

comment:4 Changed 14 years ago by yi

the function wait_for_comp could probably make use of twisted.internet.task.LoopingCall? versus basically scheduling your own callbacks. See the API documentation here:

http://twistedmatrix.com/documents/current/api/twisted.internet.task.LoopingCall.html

Other than that it looks good.

comment:5 Changed 14 years ago by robertwb

I'll look into the looping call thing more, but if it's what I think it is I'm not sure it satisfies all my needs.

The Errno url error is strange, does your urllib not support secure http connections?

Changed 14 years ago by robertwb

comment:6 Changed 14 years ago by robertwb

  • Summary changed from [with patch, positive review pending changes] Sage needs a simple api for interaction with other applications to [with patch, needs more review] Sage needs a simple api for interaction with other applications

I've re-implemented the waiting using LoopingCall?, and also reduced the amount of time it spends blocking waiting for Sage input.

I'm not sure what to do about the https error--we don't want to doctest with http as that would be a potential security vulnerability.

mhansen: what system are you getting that error on. Is it the Sage python?

comment:7 Changed 14 years ago by rlm

  • Milestone changed from sage-2.11 to sage-2.10.4

comment:8 Changed 14 years ago by robertwb

Perhaps we can use http://twistedmatrix.com/documents/current/api/twisted.web.client.html

(Need to do the same gnu-tls vs. OpenSSL trick as for the notebook.)

Changed 14 years ago by robertwb

comment:9 Changed 14 years ago by robertwb

  • Summary changed from [with patch, needs more review] Sage needs a simple api for interaction with other applications to [with patch, needs review] Sage needs a simple api for interaction with other applications

Using twisted.web.client with the reactor and all is a major pain to do interactively (e.g. for doctests), but I was able to get it to fall back to gnutls if socket.ssl (from openssl) is not available.

Changed 14 years ago by robertwb

comment:10 Changed 14 years ago by mhansen

  • Summary changed from [with patch, needs review] Sage needs a simple api for interaction with other applications to [with patch, positive review] Sage needs a simple api for interaction with other applications

Everything works for me. Apply the bundle and all three patches.

comment:11 Changed 14 years ago by mabshoff

  • Resolution set to fixed
  • Status changed from assigned to closed

Merged the bundle as well as the three patches in Sage 3.0.alpha2

Note: See TracTickets for help on using tickets.