File: gateway.py

package info (click to toggle)
pyamf 0.6.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,692 kB
  • sloc: python: 17,944; xml: 455; makefile: 116; sql: 38; java: 11; sh: 7
file content (46 lines) | stat: -rw-r--r-- 899 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import logging

import cherrypy

from pyamf.remoting.gateway.wsgi import WSGIGateway

	
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
)


def echo(data):
   """
   This is a function that we will expose.
   """
   return data


class Root(object):
    """
    This is the root controller for the rest of the website.
    """
    def index(self):
        return "This is your main website"
    index.exposed = True


config = {
    '/crossdomain.xml': {
        'tools.staticfile.on': True,
        'tools.staticfile.filename': '/path/to/crossdomain.xml'
    }
}

services = {
   'myservice.echo': echo,
   # Add other exposed functions here
}

gateway = WSGIGateway(services, logger=logging, debug=True)

# This is where we hook in the WSGIGateway
cherrypy.tree.graft(gateway, "/gateway/")
cherrypy.quickstart(Root(), config=config)