state = "Please log in below..."
username = password = ''
env={'hard_wired_users':MyCustomBackend.hard_wired_users,
- 'manifold_url':Config.manifold_url(),
+ 'manifold_url':Config.manifold_url,
}
if request.POST:
config = Config()
self.auth = auth
- self.server = config.manifold_server
- self.port = config.manifold_port
- self.path = config.manifold_path
+# self.server = config.manifold_server
+# self.port = config.manifold_port
+# self.path = config.manifold_path
self.cainfo = cainfo
self.errors = []
self.trace = []
self.calls = {}
self.multicall = False
- self.url = config.manifold_url()
+ self.url = config.manifold_url
self.proxy = xmlrpclib.Server(self.url, verbose=False, allow_none=True)
def __getattr__(self, methodName):
# it is expected to exist one such object for a given page
import json
+
from engine.prelude import Prelude
from engine.manifoldapi import ManifoldAPI
+from myslice.config import Config
# decorator to deflect calls on this Page to its prelude
def to_prelude (method):
class Page:
def __init__ (self, request):
+ self.request=request
+ # all plugins mentioned in this page
self._plugins = {}
# queue of queries
self._queue=[]
+ # global prelude object
self.prelude=Prelude(css_files='css/plugin.css')
- # no queries yet, needed ?
# load metadata
self._metadata={}
self._metadata_javascript=''
- self.load_metadata(request)
+ self.expose_js_metadata()
# record known plugins hashed on their domid
def record_plugin (self, plugin):
# the js async methods (see manifold_async_success)
# offer the option to deliver the result to a specific DOM elt
- # otherwise it goes through the pubsub using query's uuid
+ # otherwise (i.e. if domid not provided)
+ # it goes through the pubsub using query's uuid
def enqueue_query (self, query, domid=None):
self._queue.append ( (query,domid,) )
self.add_js_chunks (js)
- def load_metadata(self, request):
+ def expose_js_metadata(self):
+ request=self.request
if 'metadata' not in request.session.keys():
manifold_api_session_auth = request.session['manifold']['auth']
manifold_api = ManifoldAPI(auth=manifold_api_session_auth)
def metadata_get_fields(self, method):
return self._metadata[method]['column'].sort()
+ def expose_js_manifold_config (self):
+ self.add_js_chunks(Config.manifold_js_export())
#################### requirements/prelude management
# just forward to self.prelude - see decorator above
class Config:
- manifold_server = 'manifold.pl.sophia.inria.fr'
-# manifold_server = 'demo.myslice.info'
- manifold_port = '7080'
- manifold_path = '/'
+ # production should use https of course
+ manifold_url = "http://manifold.pl.sophia.inria.fr:7080/"
+ # exporting these details to js
@staticmethod
- def manifold_url ():
- return "http://%s:%s%s"%(Config.manifold_server,Config.manifold_port,Config.manifold_path)
+ def manifold_js_export ():
+ return "var MANIFOLD_URL = '%s';"%Config.manifold_url;
def __init__ (self, query, **settings):
Plugin.__init__ (self, **settings)
self.query=query
+ # our javascript requires the details of the manifold server
+ self.page.expose_js_manifold_config()
def template_file (self):
return "querycode.html"
(function($) {
+ $.fn.QueryCode = function( method ) {
+ /* Method calling logic */
+ if ( methods[method] ) {
+ return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
+ } else if ( typeof method === 'object' || ! method ) {
+ return methods.init.apply( this, arguments );
+ } else {
+ $.error( 'Method ' + method + ' does not exist on jQuery.QueryCode' );
+ }
+ };
+
var methods = {
init : function (options) {
console.log("temporarily turned off SyntaxHighlighter ...");
} // methods
- $.fn.QueryCode = function( method ) {
- /* Method calling logic */
- if ( methods[method] ) {
- return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
- } else if ( typeof method === 'object' || ! method ) {
- return methods.init.apply( this, arguments );
- } else {
- $.error( 'Method ' + method + ' does not exist on jQuery.QueryCode' );
- }
- };
-
// we retrieve the plugindiv as e.data - cf the 2nd arg to subscribe
- function update_plugin (e) {
+ // in fact we don't really read the published message
+ function update_plugin (e, _) {
var $plugindiv=e.data;
do_update ($plugindiv);
}
output += ' remove_const :ENABLE_NIL_PARSER\n';
output += ' const_set :ENABLE_NIL_PARSER, true\n';
output += 'end\n';
- output += 'srv = XMLRPC::Client.new2("https://www.top-hat.info/API/")\n';
- //output += 'tophat = xmlrpclib.ServerProxy("' . (TOPHAT_API_PORT == 443 ? 'http' : 'https') . '://' . TOPHAT_API_HOST . ':' . TOPHAT_API_PORT . TOPHAT_API_PATH . '", allow_none=True)\n\n';
+ output += 'srv = XMLRPC::Client.new2("' + MANIFOLD_URL + '")\n';
output += '\n';
output += '# Authentication token\n';
output += 'auth = {"AuthMethod" => "password", "Username" => "guest", "AuthString" => "guest"}\n';
});
ofs = '[' + ofs + ']';
- output += 'pp srv.call("' + query.action +'", auth, "' + query.method + '", "' + query.timestamp + '", ' + ifs + ', ' + ofs + ')';
+ output += 'pp srv.call("' + title_case(query.action) +'", auth, "' + query.method + '", "' + query.timestamp + '", ' + ifs + ', ' + ofs + ')';
var output = '<pre class="brush: ruby; toolbar: false;">' + output + "</pre>";
return output;
}
function translate_query_as_python (query) {
- // xxx tmp
- var TOPHAT_API_HOST="hostname", TOPHAT_API_PORT=443, TOPHAT_API_PATH="/path";
- var proto = (TOPHAT_API_PORT == 443 ? 'https' : 'http');
var output = '# Connection to XMLRPC server\n';
output += 'import xmlrpclib\n';
- output += 'srv = xmlrpclib.ServerProxy("' + proto + '://' + TOPHAT_API_HOST + ':' + TOPHAT_API_PORT + TOPHAT_API_PATH + '", allow_none=True)\n\n';
+ output += 'srv = xmlrpclib.ServerProxy("' + MANIFOLD_URL + '", allow_none=True)\n\n';
output += '# Authentication token\n';
output += 'auth = {"AuthMethod": "password", "Username": "name.surname@domain.name", "AuthString": "mypassword"}\n\n';
});
ofs = '[' + ofs + ']';
- output += 'srv.' + query.action + '(auth, "' + query.method + '", ' + ifs + ', {}, ' + ofs + ')';
+ output += 'srv.' + title_case(query.action) + '(auth, "' + query.method + '", ' + ifs + ', {}, ' + ofs + ')';
var output = '<pre class="brush: python; toolbar: false;">' + output + "</pre>";
return output;
}
+
+ function title_case (txt){ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}
})(jQuery); // end closure wrapper
//simplelist_debug=true;
(function($){
+
+ $.fn.SimpleList = function( method ) {
+ /* Method calling logic */
+ if ( methods[method] ) {
+ return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
+ } else if ( typeof method === 'object' || ! method ) {
+ return methods.init.apply( this, arguments );
+ } else {
+ $.error( 'Method ' + method + ' does not exist on jQuery.SimpleList' );
+ }
+ };
+
var methods = {
init : function( options ) {
return this.each(function(){
},
}; // methods
- $.fn.SimpleList = function( method ) {
- /* Method calling logic */
- if ( methods[method] ) {
- return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
- } else if ( typeof method === 'object' || ! method ) {
- return methods.init.apply( this, arguments );
- } else {
- $.error( 'Method ' + method + ' does not exist on jQuery.SimpleList' );
- }
- };
-
/* Private methods */
// complexity here is mostly because a datatables-enabled table cannot
// be updated in a "normal" way using .html()
page=page,
title="Putting stuff together",
sons=[
+ QueryCode (
+ page=page,
+ title="Vizualize your query (no syntax highlight for now)",
+ query=slices_query,
+ toggled=False,
+ ),
SliceList ( # setting visible attributes first
page=page,
title='Asynchroneous SliceList',
header='slices list',
with_datatables=False,
- toggled=False,
# this is the query at the core of the slice list
query=slices_query,
),
- QueryCode (
- page=page,
- title="Vizualize your query",
- query=slices_query,
- ),
])
# variables that will get passed to the view-plugin.html template