File: fastagisetvariable.py

package info (click to toggle)
starpy 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 360 kB
  • sloc: python: 2,899; makefile: 17
file content (28 lines) | stat: -rw-r--r-- 874 bytes parent folder | download | duplicates (4)
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
#! /usr/bin/env python
"""Try to set a FastAGI variable"""
from twisted.internet import reactor
from starpy import fastagi
import utilapplication
import logging, time

log = logging.getLogger( 'hellofastagi' )

def testFunction( agi ):
	"""Demonstrate simplistic use of the AGI interface with sequence of actions"""
	log.debug( 'testFunction' )
	def setX( ):
		return agi.setVariable( 'this"toset', 'That"2set' )
	def getX( result ):
		return agi.getVariable( 'this"toset' )
	def onX( value ):
		print 'Retrieved value', value 
		reactor.stop()
	return setX().addCallback( getX ).addCallbacks( onX, onX )

if __name__ == "__main__":
	logging.basicConfig()
	fastagi.log.setLevel( logging.DEBUG )
	APPLICATION = utilapplication.UtilApplication()
	APPLICATION.handleCallsFor( 's', testFunction )
	APPLICATION.agiSpecifier.run( APPLICATION.dispatchIncomingCall )
	reactor.run()