Ejemplo n.º 1
0
    def _urlencode_request_data(self, raw_data):
        # the data which we want to send to the server must be urlencoded
        request_data = QUrl()
        for (name, value) in raw_data.items():
            request_data.addQueryItem(name, unicode(value))

        return request_data.encodedQuery()
Ejemplo n.º 2
0
 def email_note(self):
     body = self.page.mainFrame().toPlainText()[
         len(self.title):
     ].strip()
     url = QUrl("mailto:")
     url.addQueryItem("subject", self.title)
     url.addQueryItem("body", body)
     QDesktopServices.openUrl(url)
Ejemplo n.º 3
0
    def testAllEncodedQueryItemsValues(self):
        #QUrl.allEncodedQueryItemValues
        url = QUrl()
        key = 'key'
        valid_data = ['data', 'valid', 'test']

        for i, data in enumerate(valid_data):
            url.addQueryItem(key, data)
            self.assertEqual(url.allEncodedQueryItemValues(key),
                             list(valid_data[:i+1]))
Ejemplo n.º 4
0
    def testAddQueryItem(self):
        #QUrl.addQueryItem
        url = QUrl()
        valid_data = [('hl', 'en'), ('user', 'konqui')]

        url.addQueryItem(*valid_data[0])
        self.assertEqual(url.queryItems()[0], valid_data[0])

        url.addQueryItem(*valid_data[1])
        self.assertEqual(sorted(url.queryItems()), sorted(valid_data))
Ejemplo n.º 5
0
    def testAllEncodedQueryItemsValues(self):
        #QUrl.allEncodedQueryItemValues
        url = QUrl()
        key = 'key'
        valid_data = ['data', 'valid', 'test']

        for i, data in enumerate(valid_data):
            url.addQueryItem(key, data)
            self.assertEqual(url.allEncodedQueryItemValues(key),
                             list(valid_data[:i + 1]))
Ejemplo n.º 6
0
    def testAddQueryItem(self):
        #QUrl.addQueryItem
        url = QUrl()
        valid_data = [('hl', 'en'), ('user', 'konqui')]

        url.addQueryItem(*valid_data[0])
        self.assertEqual(url.queryItems()[0], valid_data[0])

        url.addQueryItem(*valid_data[1])
        self.assertEqual(sorted(url.queryItems()), sorted(valid_data))
Ejemplo n.º 7
0
    def get_oauth_url(self, app_id, redirect_uri, scope, state, response_type,
            display):
        """
        Return encoded OAuth URL with request params formated as GET params.

        @param app_id        (str/uni)
        @param redirect_uri  (str/uni)
        @param scope         (list)
        @param state         (str/uni)
        @param response_type (str/uni)
        @param display       (str/uni)

        @return (QUrl)
        """

        if type(app_id) not in (str, unicode):
            raise FBAuthDialogInvalidParamException(
                "app_id must be `str` or `unicode` but was: %s" % type(app_id))

        if type(redirect_uri) not in (type(None), str, unicode):
            raise FBAuthDialogInvalidParamException(
                "redirect_uri must be `None`, `str` or `unicode` but was: %s" %
                type(redirect_uri))

        if type(scope) not in (type(None), list):
            raise FBAuthDialogInvalidParamException(
                "scope must be `None` or `list` but was: %s" %
                type(scope))

        if type(state) not in (type(None), str, unicode):
            raise FBAuthDialogInvalidParamException(
                "state must be `None`, `str` or `unicode` but was: %s" %
                type(state))

        if type(response_type) not in (type(None), str, unicode):
            raise FBAuthDialogInvalidParamException(
                "response_type must be `None`, `str` or `unicode` but was: %s"
                % type(response_type))

        if type(display) not in (type(None), str, unicode):
            raise FBAuthDialogInvalidParamException(
                "display must be `None`, `str` or `unicode` but was: %s"
                % type(display))

        url = QUrl(OAUTH_URL)

        url.addQueryItem("client_id", app_id)
        url.addQueryItem("redirect_uri", redirect_uri)
        url.addQueryItem("response_type", response_type)
        url.addQueryItem("display", display)

        if scope:
            _scope = ",".join(map(unicode, scope))

            url.addQueryItem("scope", _scope)

        if state:
            url.addQueryItem("state", state)

        return url
Ejemplo n.º 8
0
 def email_note(self):
     body = self.page.mainFrame().toPlainText()[len(self.title):].strip()
     url = QUrl("mailto:")
     url.addQueryItem("subject", self.title)
     url.addQueryItem("body", body)
     QDesktopServices.openUrl(url)
Ejemplo n.º 9
0
Archivo: t1.py Proyecto: zjx4041739/dlp
    def _urlencode_post_data(self, post_data):
        post_params = QUrl()
        for (key, value) in post_data.items():
            post_params.addQueryItem(key, unicode(value))

        return post_params.encodedQuery()