eBay.py - Has anyone looked at this???

provato provato at gmail.com
Thu Jul 14 17:41:35 EDT 2005


I'm somewhat of a newbie was confused by the following code that I
downloaded from eBay's developer site:

One of the classes in the file is called "Call". What I don't get is
that in "MakeCall" function, there's a use of self.Session.Server.
Where is this property coming from?




============================================



class Call:
    RequestData = "<xml />"  # just a stub
    DetailLevel = "0"
    SiteID = "0"

    def MakeCall(self, CallName):
        # specify the connection to the eBay Sandbox environment
        # TODO: Make this configurable in eBay.ini (sandbox/production)
        conn = httplib.HTTPSConnection(self.Session.Server)

        # specify a POST with the results of generateHeaders and
generateRequest
        conn.request("POST", self.Session.Command, self.RequestData,
self.GenerateHeaders(self.Session, CallName))
        response = conn.getresponse()

        # TODO: When you add logging to this, change the
        # following to log statements
        # print "Response status:", response.status
        # print "Response reason:", response.reason

        # store the response data and close the connection
        data = response.read()
        conn.close()

        responseDOM = parseString(data)

        # check for any <Error> tags and print
        # TODO: Return a real exception and log when this happens
        tag = responseDOM.getElementsByTagName('Error')
        if (tag.count!=0):
            for error in tag:
                print "\n",error.toprettyxml("  ")

        return responseDOM

    def GenerateHeaders(self, Session, CallName):
        headers = {"X-EBAY-API-COMPATIBILITY-LEVEL": "349",
                   "X-EBAY-API-SESSION-CERTIFICATE": Session.Developer
+ ";" + Session.Application + ";" + Session.Certificate,
                   "X-EBAY-API-DEV-NAME": Session.Developer,
                   "X-EBAY-API-APP-NAME": Session.Application,
                   "X-EBAY-API-CERT-NAME": Session.Certificate,
                   "X-EBAY-API-CALL-NAME": CallName,
                   "X-EBAY-API-SITEID": self.SiteID,
                   "X-EBAY-API-DETAIL-LEVEL": self.DetailLevel,
                   "Content-Type": "text/xml"}
        return headers




More information about the Python-list mailing list