Package web2py :: 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=1)
x.__init__(...) initializes x; see x.__class__.__doc__ 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
 
xmlrpc(self, f)
example:
source code
 
amfrpc(self, f)
example:
source code
 
amfrpc3(self, domain='default')
example:
source code
 
soap(self, name=1, returns=1, args=1, doc=1)
example::...
source code
 
serve_run(self, args=1) source code
 
serve_csv(self, args=1) source code
 
serve_xml(self, args=1) source code
 
serve_rss(self, args=1) source code
 
serve_json(self, args=1) source code
 
serve_jsonrpc(self) 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(globals()) @service.run @service.rss @service.json @service.jsonrpc @service.xmlrpc @service.jsonrpc @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__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, environment=1)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

run(self, f)

source code 
example:
   service = Service(globals())
   @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(globals())
   @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(globals())
   @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(globals())
   @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(globals())
   @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(globals())
   @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

xmlrpc(self, f)

source code 
example:
   service = Service(globals())
   @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(globals())
   @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(globals())
   @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=1, returns=1, args=1, doc=1)

source code 

example::

    service = Service(globals())
    @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(globals()) @service.run @service.rss @service.json @service.jsonrpc @service.xmlrpc @service.jsonrpc @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