def __init__(self, url, customHeaders={}, handleEncoding=False, cookieReg=None): ZSimpleXmlHTTPRequest.__init__(self, url, customHeaders, handleEncoding, cookieReg)
def __init__(self, url, username, password, debug = False): atomHeaders = {} atomHeaders[u"Accept"] = u"application/atom+xml; text/html; text/xml; text/plain" #$NON-NLS-2$ #$NON-NLS-1$ atomHeaders[u"Content-Type"] = u"application/atom+xml" #$NON-NLS-2$ #$NON-NLS-1$ ZSimpleXmlHTTPRequest.__init__(self, url, atomHeaders) self.setAuthorization(username, password) self.errorData = None self.dom = None self.debug = debug self.logger = None
class ZFeedbackBackgroundTask(ZBackgroundTask): def __init__(self): self.endpoint = None self.customAttributes = {} self.connection = None ZBackgroundTask.__init__(self) # end __init__() def initialize(self, endpoint, feedback, version): self.endpoint = endpoint self.feedback = feedback self.version = version self.setName(_extstr(u"feedbackimpl.SendingFeedback")) #$NON-NLS-1$ self.setNumWorkUnits(2) # end initialize() def getCustomAttributes(self): return self.customAttributes # end getCustomAttributes() def setCustomAttributes(self, attributeMap): self.customAttributes = attributeMap # end setCustomAttributes() def isResumable(self): return False # end isResumable() def _doCancel(self): if self.connection: self.connection.close() # end _doCancel() def _run(self): self._incrementWork(_extstr(u"feedbackimpl.FeedbackInformationGathered_"), 1, True) #$NON-NLS-1$ self.connection = ZSimpleXmlHTTPRequest(self.endpoint) postData = { u"name" : u"N/A", #$NON-NLS-2$ #$NON-NLS-1$ u"email" : self.feedback.getEmail(), #$NON-NLS-1$ u"title" : self.feedback.getSubject(), #$NON-NLS-1$ u"description" : self.feedback.getFeedback(), #$NON-NLS-1$ u"timestamp" : unicode(self.feedback.getTimestamp()), #$NON-NLS-1$ u"version" : self.version.getFullVersionString(), #$NON-NLS-1$ u"blogplatform" : u"N/A", #$NON-NLS-1$ #$NON-NLS-2$ u"reporttype" : self.feedback.getType(), #$NON-NLS-1$ u"pubsites" : u"N/A", #$NON-NLS-1$ #$NON-NLS-2$ } if self.connection.send(postData): self.connection.getResponse() else: raise ZException(_extstr(u"feedbackimpl.SendingFeedbackFailed")) #$NON-NLS-1$ self._incrementWork(_extstr(u"feedbackimpl.FeedbackSent"), 1, True) #$NON-NLS-1$
def convertProductLink(self, productUrl, zoundryServiceId): postData = self._getAddProductPostDataForUrl(productUrl, zoundryServiceId) headers = { u"Content-Type" : u"text/xml", #$NON-NLS-2$ #$NON-NLS-1$ u"Content-Length" : u"%d" % len(postData) #$NON-NLS-1$ #$NON-NLS-2$ } request = ZSimpleXmlHTTPRequest(ADD_PRODUCT_ENDPOINT, headers, True) if request.send(postData): dom = request.getResponse() respCode = dom.selectSingleNodeText(u"/Response/Status/Code") #$NON-NLS-1$ if respCode == u"200": #$NON-NLS-1$ return dom.selectSingleNodeText(u"/Response/AddProductsResponse/Product/ProxyUrl").strip() #$NON-NLS-1$ return None
def getLatestVersionInfo(self): appModel = getApplicationModel() build = unicode(appModel.getVersion().getBuild()) userProfile = appModel.getUserProfile() userPrefs = userProfile.getPreferences() guid = userPrefs.getUserPreference(IZAppUserPrefsKeys.GUID, u"") #$NON-NLS-1$ url = self.versionXmlUrl % (guid, build) self.logger.debug(u"Getting latest version at URL: %s" % url) #$NON-NLS-1$ request = ZSimpleXmlHTTPRequest(url) try: if request.send(): return ZLatestVersionInfo(request.getResponse()) except Exception, e: self.logger.exception(e)
def _getAuthSchemeFromResponse(self, httpResponse): # return wsse for tp scheme = ZSimpleXmlHTTPRequest._getAuthSchemeFromResponse(self, httpResponse) if not scheme: # use xwsse as default. (Typepad does not return auth scheme - bug) scheme = ZXWsseUsernameAuthHandler.SCHEME return scheme
def _processPostData(self, postData): data = postData if data and isinstance(data, ZAtomDocument): data = postData.getDom() # entry zdom data = ZSimpleXmlHTTPRequest._processPostData(self, data) self._logPostData(data) return data
def convertProductLink(self, productUrl, zoundryServiceId): postData = self._getAddProductPostDataForUrl(productUrl, zoundryServiceId) headers = { u"Content-Type": u"text/xml", #$NON-NLS-2$ #$NON-NLS-1$ u"Content-Length": u"%d" % len(postData) #$NON-NLS-1$ #$NON-NLS-2$ } request = ZSimpleXmlHTTPRequest(ADD_PRODUCT_ENDPOINT, headers, True) if request.send(postData): dom = request.getResponse() respCode = dom.selectSingleNodeText( u"/Response/Status/Code") #$NON-NLS-1$ if respCode == u"200": #$NON-NLS-1$ return dom.selectSingleNodeText( u"/Response/AddProductsResponse/Product/ProxyUrl").strip( ) #$NON-NLS-1$ return None
def _run(self): self._incrementWork(_extstr(u"feedbackimpl.FeedbackInformationGathered_"), 1, True) #$NON-NLS-1$ self.connection = ZSimpleXmlHTTPRequest(self.endpoint) postData = { u"name" : u"N/A", #$NON-NLS-2$ #$NON-NLS-1$ u"email" : self.feedback.getEmail(), #$NON-NLS-1$ u"title" : self.feedback.getSubject(), #$NON-NLS-1$ u"description" : self.feedback.getFeedback(), #$NON-NLS-1$ u"timestamp" : unicode(self.feedback.getTimestamp()), #$NON-NLS-1$ u"version" : self.version.getFullVersionString(), #$NON-NLS-1$ u"blogplatform" : u"N/A", #$NON-NLS-1$ #$NON-NLS-2$ u"reporttype" : self.feedback.getType(), #$NON-NLS-1$ u"pubsites" : u"N/A", #$NON-NLS-1$ #$NON-NLS-2$ } if self.connection.send(postData): self.connection.getResponse() else: raise ZException(_extstr(u"feedbackimpl.SendingFeedbackFailed")) #$NON-NLS-1$ self._incrementWork(_extstr(u"feedbackimpl.FeedbackSent"), 1, True) #$NON-NLS-1$
def _processResponseData(self, resp, txt): dom = None if txt and len( txt.strip() ) > 0: self._logRespData(txt) dom = ZSimpleXmlHTTPRequest._processResponseData(self, resp, txt) self._setDomNSS(dom) elif resp.status >= 200 and resp.status <= 299: txt = u"Empty response data. Http code %d for URI %s" % (resp.status, self.url) #$NON-NLS-1$ self._debug(txt ) # create place holder dom dom = self._createEmptyFeed() else: txt = u"Empty response data. Http code %d for URI %s" % (resp.status, self.url) #$NON-NLS-1$ self._error(txt) self.dom = dom return dom
def __init__(self, url, customHeaders, zBlogServerMediaUploadListener = None): self.listener = zBlogServerMediaUploadListener ZSimpleXmlHTTPRequest.__init__(self, url, customHeaders)
def _atomProcessError(self, resp): self.errorData = ZSimpleXmlHTTPRequest._processError(self, resp) self._logErrorResponse(self.errorData)
def __init__(self, url, customHeaders, zBlogServerMediaUploadListener=None): self.listener = zBlogServerMediaUploadListener ZSimpleXmlHTTPRequest.__init__(self, url, customHeaders)
def __init__(self, url, customHeaders = {}, handleEncoding = False, cookieReg = None): ZSimpleXmlHTTPRequest.__init__(self, url, customHeaders, handleEncoding, cookieReg)