Ok folks, not exactly the way i would like to do it but I found a workaround to do it and i would like to share it with others so maybe a better approach can rise...
I decided to give a try at the REST API, this ended like this: import requests url = "http://localhost:2480/function/test/get_all_car" r = requests.get(url, auth=('login', 'password')) print r.json() which give me the same result as in my browser! While this work and i can now find my way in my issue, this will introduce a new dependency in my project and that could have been avoided with a more official way of doing it. Any comment are welcome Thanks DjO Le mercredi 3 décembre 2014 12:20:09 UTC+1, DjO a écrit : > > Hi folks, > > Sorry for the noise, I search the documentation, this group and even read > Getting started with OrientDB book but wasn't able to find a way to call > server-side functions from SQL calls on the client side. > Let me give some precision... > > - First of all and most importantly I'm using Python and interact with an > instance of OrientDB-2.0M3 by using a patched pyorient driver. (Actually, i > just bump up the *SUPPORTED_PROTOCOL* version to 26) And both snapshots > are 3 days old (2014/12/03) > - I register some SQL and JavaScript server-side functions in OrientDB > using Studio. > - I edited orientdb-server-config.xml like this: > <handler > class="com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter"> > <parameters> > <parameter name="enabled" value="true"/> > <parameter name="allowedLanguages" value="SQL,Javascript"/> > </parameters> > </handler> > > Now let's say I have a function SQL function called get_all_car > > *In the navigator, searching for:* > *http://localhost:2480/function/test/get_all_car > <http://localhost:2480/function/test/get_all_car>* > > *Give me:* > > {"result":[{"@type":"d","@rid":"#14:1","@version":12,"@class":"Car","name":"Ferrari"}]} > > > Exactly what I want!!! > > > > *In the console, I have to call the function like this:* > *SELECT get_all_car()* > > *Calls like this doesn't work:* > *get_all_car* or *get_all_car()* > > *And give me:* > { > "result": [ > { > "@type": "d", > "@rid": "#-2:0", > "@version": 0, > "get_all_car": [ > "#14:1" > ] > } > ], > "notification": "Query executed in 0.018 sec. Returned 1 record(s)" > } > > Not exactly what i was looking for and I get exactly the same result when > i run the query from python like this: > *client.command('select get_all_car()')* > > I pretty sure that I'm doing a noob job and that my issues are related to > the way I'm calling my custom function from SQL or this is maybe related to > pyorient. > Anyway, Question: > I would like to put my business logic on the server with using SQL and/or > JavaScript custom command. What is the proper way to call those functions > from outside and get result similar to those given in the functions tab of > Studio? > Ideally, I would like to be able to do something like that in python: > *client.command('get_all_car()')* > > Maybe this is more a pyorient request to made or implement my self, but > before diving into this advice on the best way to do it in regular query > from a client are welcome!!!! > > Again, sorry for the noise if this have already been covered in previous > post! > > Thanks > DjO > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
