Question regarding pyamf.remoting.client.RemotingService

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Question regarding pyamf.remoting.client.RemotingService

Vijay shan
  I am trying to write a test client for some pyamf services. The general structure os the services is that the user logs in and then the subsequent calls check to see if the current user is logged in before they send data. My client is working well when i log in. The subsequent calls seem to fail because the session is lost. I tried subclassing RemotingService and getting the set-cookie to the value returned by the first call but that did not work either. Please let me know if there is something I am missing.


=========== Begin code ============

import sys
from optparse import OptionParser
import urllib2
from pyamf import remoting

from pyamf.remoting.client import RemotingService

class RemotingServiceSpecial(RemotingService):

    def _getResponse(self, http_request):
            fbh = self.opener(http_request)
        except urllib2.URLError, e:
            if self.logger:
                self.logger.exception('Failed request for %s',

            raise remoting.RemotingError(str(e))
        http_message = fbh.info()
        setcookie = http_message.getheader('Set-Cookie')
        if setcookie is not None:
            self.http_headers['Set-Cookie'] = setcookie
        return super(RemotingServiceSpecial,self)._getResponse(http_request)

parser = OptionParser()
parser.add_option("-p", "--port", default=8000,
    dest="port", help="port number [default: %default]")
parser.add_option("--host", default="localhost",
    dest="host", help="host address [default: %default]")
(options, args) = parser.parse_args()

url = 'http://%s:%d/authentication_gateway/' % (options.host, int(options.port))
server = RemotingServiceSpecial(url)
print 'Connecting to %s\n' % url

# call service to fetch intro text
service_list = ['auth_service.login', 'auth_service.logout', 'auth_service.is_user_logged_in', 'auth_service.get_groups']
service_obj_list = []
for i in service_list:
    print i
    intro = server.getService(i,auto_execute=False)
    print intro

print service_obj_list

service = server.getService('auth_service')

val = service.login('vijayshan','723edc')
print val
print service.is_user_logged_in()

============end code=========

PyAMF users mailing list - [hidden email]