Package gluon :: Module tools :: Class Service
[hide private]
[frames] | no frames]

Class Service

source code

object --+
         |
        Service

Nested Classes [hide private]
  JsonRpcException
Instance Methods [hide private]
 
__init__(self, environment=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
run(self, f)
example:
source code
 
csv(self, f)
example:
source code
 
xml(self, f)
example:
source code
 
rss(self, f)
example:
source code
 
json(self, f)
example:
source code
 
jsonrpc(self, f)
example:
source code
 
jsonrpc2(self, f)
example:
source code
 
xmlrpc(self, f)
example:
source code
 
amfrpc(self, f)
example:
source code
 
amfrpc3(self, domain='default')
example:
source code
 
soap(self, name=None, returns=None, args=None, doc=None)
example:
source code
 
serve_run(self, args=None) source code
 
serve_csv(self, args=None) source code
 
serve_xml(self, args=None) source code
 
serve_rss(self, args=None) source code
 
serve_json(self, args=None) source code
 
serve_jsonrpc(self) source code
 
serve_jsonrpc2(self, data=None, batch_element=False) source code
 
serve_xmlrpc(self) source code
 
serve_amfrpc(self, version=0) source code
 
serve_soap(self, version='1.1') source code
 
__call__(self)
register services with: service = Service() @service.run @service.rss @service.json @service.jsonrpc @service.xmlrpc @service.amfrpc @service.amfrpc3('domain') @service.soap('Method', returns={'Result':int}, args={'a':int,'b':int,})
source code
 
error(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  jsonrpc_errors = {-32700: ('Parse error. Invalid JSON was rece...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, environment=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

run(self, f)

source code 

example:

    service = Service()
    @service.run
    def myfunction(a, b):
        return a + b
    def call():
        return service()

Then call it with:

    wget http://..../app/default/call/run/myfunction?a=3&b=4

csv(self, f)

source code 

example:

    service = Service()
    @service.csv
    def myfunction(a, b):
        return a + b
    def call():
        return service()

Then call it with:

    wget http://..../app/default/call/csv/myfunction?a=3&b=4

xml(self, f)

source code 

example:

    service = Service()
    @service.xml
    def myfunction(a, b):
        return a + b
    def call():
        return service()

Then call it with:

    wget http://..../app/default/call/xml/myfunction?a=3&b=4

rss(self, f)

source code 

example:

    service = Service()
    @service.rss
    def myfunction():
        return dict(title=..., link=..., description=...,
            created_on=..., entries=[dict(title=..., link=...,
                description=..., created_on=...])
    def call():
        return service()

Then call it with:

    wget http://..../app/default/call/rss/myfunction

json(self, f)

source code 

example:

    service = Service()
    @service.json
    def myfunction(a, b):
        return [{a: b}]
    def call():
        return service()

Then call it with:

    wget http://..../app/default/call/json/myfunction?a=hello&b=world

jsonrpc(self, f)

source code 

example:

    service = Service()
    @service.jsonrpc
    def myfunction(a, b):
        return a + b
    def call():
        return service()

Then call it with:

    wget http://..../app/default/call/jsonrpc/myfunction?a=hello&b=world

jsonrpc2(self, f)

source code 

example:

    service = Service()
    @service.jsonrpc2
    def myfunction(a, b):
        return a + b
    def call():
        return service()

Then call it with:

    wget --post-data '{"jsonrpc": "2.0", "id": 1, "method": "myfunction", "params": {"a": 1, "b": 2}}' http://..../app/default/call/jsonrpc2

xmlrpc(self, f)

source code 

example:

    service = Service()
    @service.xmlrpc
    def myfunction(a, b):
        return a + b
    def call():
        return service()

The call it with:

    wget http://..../app/default/call/xmlrpc/myfunction?a=hello&b=world

amfrpc(self, f)

source code 

example:

    service = Service()
    @service.amfrpc
    def myfunction(a, b):
        return a + b
    def call():
        return service()

The call it with:

    wget http://..../app/default/call/amfrpc/myfunction?a=hello&b=world

amfrpc3(self, domain='default')

source code 

example:

    service = Service()
    @service.amfrpc3('domain')
    def myfunction(a, b):
        return a + b
    def call():
        return service()

The call it with:

    wget http://..../app/default/call/amfrpc3/myfunction?a=hello&b=world

soap(self, name=None, returns=None, args=None, doc=None)

source code 

example:

    service = Service()
    @service.soap('MyFunction',returns={'result':int},args={'a':int,'b':int,})
    def myfunction(a, b):
        return a + b
    def call():
        return service()

The call it with:

    from gluon.contrib.pysimplesoap.client import SoapClient
    client = SoapClient(wsdl="http://..../app/default/call/soap?WSDL")
    response = client.MyFunction(a=1,b=2)
    return response['result']

Exposes online generated documentation and xml example messages at:
- http://..../app/default/call/soap

__call__(self)
(Call operator)

source code 

register services with: service = Service() @service.run @service.rss @service.json @service.jsonrpc @service.xmlrpc @service.amfrpc @service.amfrpc3('domain') @service.soap('Method', returns={'Result':int}, args={'a':int,'b':int,})

expose services with

def call(): return service()

call services with http://..../app/default/call/run?[parameters] http://..../app/default/call/rss?[parameters] http://..../app/default/call/json?[parameters] http://..../app/default/call/jsonrpc http://..../app/default/call/xmlrpc http://..../app/default/call/amfrpc http://..../app/default/call/amfrpc3 http://..../app/default/call/soap


Class Variable Details [hide private]

jsonrpc_errors

Value:
{-32700: ('Parse error. Invalid JSON was received by the server.',
          'An error occurred on the server while parsing the JSON text\
.'),
 -32603: ('Internal error', 'Internal JSON-RPC error.'),
 -32602: ('Invalid params', 'Invalid method parameter(s).'),
 -32601: ('Method not found',
          'The method does not exist / is not available.'),
 -32600: ('Invalid Request', 'The JSON sent is not a valid Request obj\
...