RestOC.REST module

REST Module

Provides interfaces for creating and maintaining REST servers

class RestOC.REST.Config(conf)

Bases: object

Config class

Represents configuration data for connecting to/loading services

__contains__(service)

Python magic method for checking a key exists in a dict like object

Parameters

service (str) – The service to check for

Returns

bool

__getitem__(service)

Python magic method for getting a key from a dict like object

Parameters

{str} (service) – The service config to return

Raises

KeyError

Returns

mixed

__init__(conf)

Constructor

Initialises the instance

Parameters

{dict} (conf) – The configuration data for compiling the list of services and loaders

Returns

Config

__iter__()

Python magic method to return an iterator for the instance

Returns

iterator

__str__()

Python magic method to return a string for the instance

Returns

str

keys()

services

Returns the keys (services) in the instance

Returns

str[]

class RestOC.REST.Server(routes, service='', cors=None, error_callback=None)

Bases: bottle.Bottle

Creates an HTTP server for use with REST requests

__init__(routes, service='', cors=None, error_callback=None)

Constructor (__init__)

Instantiates the server instance

Parameters
  • routes (dict|list) – Routes to the server

  • service (str) – The service to use if none exists in a route

  • cors (str) – The regex to identify allowed domains

  • error_callback (function) – A function to call if any exception occurs

Returns

None

run(server='gunicorn', host='127.0.0.1', port=8080, reloader=False, interval=1, quiet=False, plugins=None, debug=None, maxfile=20971520, **kargs)

Run

Overrides Bottle’s run to default gunicorn and other fields

Parameters
  • server (str) – Server adapter to use

  • host (str) – Server address to bind to

  • port (int) – Server port to bind to

  • reloader (bool) – Start auto-reloading server?

  • interval (int) – Auto-reloader interval in seconds

  • quiet (bool) – Suppress output to stdout and stderr?

  • plugins (list) – List of plugins to the server

  • debug (bool) – Debug mode

  • maxfile (int) – Maximum size of requests

Returns

None