def __call__(self, http_request): new = False try: key = http_request.COOKIES["SESSION_KEY"] http_request.session = Session.get(key) except KeyError: new = True http_request.session = Session() http_request.session.put() try: http_response = DjangoGateway.__call__(self, http_request) finally: if new: http_response.set_cookie("SESSION_KEY", http_request.session.key()) return http_response
def __call__(self, http_request): new = False try: key = http_request.COOKIES['SESSION_KEY'] http_request.session = Session.get(key) except KeyError: new = True http_request.session = Session() http_request.session.put() try: http_response = DjangoGateway.__call__(self, http_request) finally: if new: http_response.set_cookie('SESSION_KEY', http_request.session.key()) return http_response
try: old_stdout = sys.stdout old_stderr = sys.stderr try: sys.stdout = buffer sys.stderr = buffer self._evalCode(statement, session) finally: sys.stdout = old_stdout sys.stderr = old_stderr except: buffer.write(traceback.format_exc()) return buffer.getvalue() def startup(self, request): pyamf_version = '.'.join([str(x) for x in pyamf.__version__]) header = 'Welcome to the PyAMF %s Shell Demo!\n' \ 'Python %s on %s\n' \ 'Type "help", "copyright", "credits" or "license" for more information.' % \ (pyamf_version, sys.version, sys.platform) return header services = {'shell': ShellService()} gateway = DjangoGateway(services)
try: old_stdout = sys.stdout old_stderr = sys.stderr try: sys.stdout = buffer sys.stderr = buffer self._evalCode(statement, session) finally: sys.stdout = old_stdout sys.stderr = old_stderr except: buffer.write(traceback.format_exc()) return buffer.getvalue() def startup(self, request): pyamf_version = '.'.join([str(x) for x in pyamf.__version__]) header = 'Welcome to the PyAMF %s Shell Demo!\n' \ 'Python %s on %s\n' \ 'Type "help", "copyright", "credits" or "license" for more information.\n' % \ (pyamf_version, sys.version, sys.platform) return header services = {'shell': ShellService()} gateway = DjangoGateway(services, debug=True, logger=logging)
# -*- coding: utf-8 -*- import pyamf, json from pyamf.remoting.gateway.django import DjangoGateway from django.http import HttpResponse from vo import makeVo, CardVO, HeroVO import card import hero pyamf.register_class(CardVO, 'CardVO') pyamf.register_class(HeroVO, 'HeroVO') services = { "cardService.getAllCards": card.CardService.getAllCards, #"heroService.getAllHeros":hero.HeroService.getAllHeros, "heroService.createUserHeros": hero.HeroService.createUserHeros, "heroService.updateUserHeros": hero.HeroService.updateUserHeros, "heroService.getAllSystemAndUserHeros": hero.HeroService.getAllSystemAndUserHeros, "heroService.deleteUserHeros": hero.HeroService.deleteUserHeros, } gateway = DjangoGateway(services, expose_request=False, debug=True)
# Copyright (c) The PyAMF Project. # See LICENSE.txt for details. import logging from pyamf.remoting.gateway.django import DjangoGateway import python.gateway.views as views from python.settings import DEBUG services = { 'ByteArray.saveSnapshot': views.save_snapshot, 'getSnapshots': views.get_snapshots } gw = DjangoGateway(services, logger=logging, debug=DEBUG)
@task def recharge(self, data): OnlineTransfer(data) # Finally to expose django views use DjangoGateway agw = DjangoGateway({ "ActionService.beepRequest": beepRequest, "ActionService.messageRequest": messageRequest, "ActionService.calculator": calculator, "ActionService.refund": refund, "ActionService.cardRequest": cardRequest, "ActionService.queryTransaction": queryTransaction, "ActionService.issueTransaction": issueTransaction, "ActionService.rescheduleTransaction": rescheduleTransaction, "ActionService.retry": retry, "ActionService.updateTransaction": updateTransaction, "ActionService.logger": logger, "ActionService.log_bal": log_bal, "ActionService.sendMessage": sendMessage, "ActionService.schedule": schedule, "ActionService.mobifin_recharge": mobifin_recharge, "ActionService.mobifin_card_recharge": mobifin_card_recharge, "ActionService.mobifin_balance": mobifin_balance, "ActionService.mobifin_echo": mobifin_echo, "ActionService.calling_card": calling_card, "ActionService.counter": counter, "ActionService.card_to_db": card_to_db, "ActionService.ping": ping, })
'admin.deleteUser':a.deleteUser, 'admin.getUserDetail':a.getUserDetail, 'admin.createActiveObject':a.createActiveObject, 'admin.updateActiveObject':a.updateActiveObject, 'admin.deleteActiveObject':a.deleteActiveObject, 'admin.getActiveObjectInfo':a.getActiveObjectDetail, 'admin.queryLoginList':a.queryLoginList, 'admin.login':a.login, 'admin.logout':a.logout, 'admin.getSysParamList':a.getSysParamList, 'admin.getSysParamInfo':a.getSysParamInfo, 'admin.createSysParam':a.createSysParam, 'admin.updateSysParam':a.updateSysParam, 'admin.deleteSysParam':a.deleteSysParam, 'admin.getAoNearestGpsData':a.getAoNearestGpsData, 'admin.getUserMessageList':a.getUserMessageList, 'admin.deleteUserMessage':a.deleteUserMessage, 'admin.replyUserMessage':a.replyUserMessage,# } gateway = DjangoGateway(services, expose_request=True)
from pyamf.remoting.gateway.django import DjangoGateway import iface def echo(data): 'simple echo function, for basic testing purpose' return data #available services services = { 'traveler.echo': echo, 'traveler.addCity': iface.addCity, 'traveler.addRoute': iface.addRoute, 'traveler.addCityToRoute': iface.addCityToRoute, 'traveler.delCity': iface.delCity, 'traveler.delRoute': iface.delRoute, 'traveler.delCityFromRoute': iface.delCityFromRoute, 'traveler.getCities': iface.getCities, 'traveler.getRoutes': iface.getRoutes, 'traveler.getCitiesInRoute': iface.getCitiesInRoute, 'traveler.setHomeCity': iface.setHomeCity, 'traveler.tspSolve': iface.tspSolve, 'traveler.tspState': iface.tspState, 'traveler.tspResult': iface.tspResult, } #open pyamf gateway, discard 'request' argument in service - handling functions gateway = DjangoGateway(services, expose_request=False)
res = task_request(obj, 'www.arooko.ngrok.com', syn.method) # the receiver should ack=True #if res == 'success': #Sync.objects.filter(id=syn.id).update(ack=True) def notify(request): global notice, count if count != 1: notice = notification.schedule(delay=(60 * 5)) # there should be one at a time count += 1 get_balance() def revoker(request): global notice, count notice.revoke() count = 0 # Finally to expose django views use DjangoGateway sync = DjangoGateway({"SyncService.register": register, "SyncService.update_user": update_user, "SyncService.update_wallet": update_wallet, "SyncService.update_offline_wallet": update_offline_wallet, "SyncService.update_schedule": update_schedule, "SyncService.update_transaction": update_transaction, "SyncService.create_transaction": create_transaction, "SyncService.sync_down": sync_down, "SyncService.notify": notify, "SyncService.revoker": revoker, })
from pyamf.remoting.gateway.django import DjangoGateway from mediagate import views services = { 'mediagate.getFile': views.getfile, } mediagateGateway = DjangoGateway(services)
def gateway(self): return DjangoGateway(self.get_methods(), expose_request=False)