Esempio n. 1
0
    def __str__(self):
        '''
        This method returns a string representation of the Form object.
        
        >>> f = Form()
        >>> _ = f.addInput([("type", "text"), ("name", "abc"), ("value", "123")])
        >>> str(f)
        'abc=123'

        >>> f = Form()
        >>> _ = f.addInput([("type", "text"), ("name", "abc"), ("value", "123")])
        >>> _ = f.addInput([("type", "text"), ("name", "def"), ("value", "000")])        
        >>> str(f)
        'abc=123&def=000'
        
        >>> import urllib
        >>> f = Form() # Default encoding UTF-8
        >>> _ = f.addInput([("type", "text"), ("name", u"v"),("value", u"áéíóú")])
        >>> _ = f.addInput([("type", "text"), ("name", u"c"), ("value", u"ñçÑÇ")])
        >>> f.addSubmit('address', 'bsas')
        >>> urllib.unquote(str(f)).decode('utf-8') == u'c=ñçÑÇ&address=bsas&v=áéíóú'
        True

        @return: string representation of the Form object.
        '''
        #
        # FIXME: hmmm I think that we are missing something here... what about
        # self._select values. See FIXME below.
        #
        d = dict(self)
        d.update(self._submitMap)
        return urlencode(d, encoding=self.encoding)
Esempio n. 2
0
 def __str__( self ):
     '''
     This method returns a string representation of the dataContainer Object.
     
     @return: string representation of the dataContainer Object.
     '''
     return urlencode( self )
Esempio n. 3
0
    def __str__( self ):
        '''
        This method returns a string representation of the form Object.
        
        >>> f = form()
        >>> _ = f.addInput( [("type", "text") , ("name", "abc") , ("value", "123")] )
        >>> str(f)
        'abc=123'

        >>> f = form()
        >>> _ = f.addInput( [("type", "text") , ("name", "abc") , ("value", "123")] )
        >>> _ = f.addInput( [("type", "text") , ("name", "def") , ("value", "000")] )        
        >>> str(f)
        'abc=123&def=000'

        @return: string representation of the form Object.
        '''
        tmp = self.copy()
        for i in self._submitMap:
            tmp[i] = self._submitMap[i]
        
        #
        # FIXME: hmmm I think that we are missing something here... what about
        # self._select values. See FIXME below. Maybe we need another for?
        #

        return urlencode(tmp)
Esempio n. 4
0
 def __str__(self):
     '''
     >>> str(QueryString([('a','>'), ('b', ['a==1 && z >= 2','3>2'])]))
     'a=%3E&b=a%3D%3D1%20%26%26%20z%20%3E%3D%202&b=3%3E2'
     >>> str(QueryString([('a', 'x=/etc/passwd')]))
     'a=x%3D%2Fetc%2Fpasswd'
 
     @return: string representation of the QueryString object.
     '''
     return enc_dec.urlencode(self, encoding=self.encoding, safe='')
Esempio n. 5
0
    def __str__(self):
        '''
        >>> str(QueryString([('a','>'), ('b', ['a==1 && z >= 2','3>2'])]))
        'a=%3E&b=a%3D%3D1%20%26%26%20z%20%3E%3D%202&b=3%3E2'
        >>> str(QueryString([('a', 'x=/etc/passwd')]))
        'a=x%3D%2Fetc%2Fpasswd'

        :return: string representation of the QueryString object.
        '''
        return enc_dec.urlencode(self, encoding=self.encoding, safe='')
Esempio n. 6
0
    def __str__( self ):
        '''
        This method returns a string representation of the dataContainer Object.
        
        >>> dc = dataContainer( [('a','1') , ('b', ['2','3']) ] )
        >>> str(dc)
        'a=1&b=2&b=3'
        
        >>> dc = dataContainer( [('a','1') , ('b', '2') ] )
        >>> str(dc)
        'a=1&b=2'

        @return: string representation of the dataContainer Object.
        '''
        return urlencode( self )
Esempio n. 7
0
    def __str__( self ):
        '''
        This method returns a string representation of the form Object.
        @return: string representation of the form Object.
        '''
        tmp = self.copy()
        for i in self._submitMap:
            tmp[i] = self._submitMap[i]
        
        #
        #   FIXME: hmmm I think that we are missing something here... what about self._select values. See FIXME below.
        #   Maybe we need another for?
        #

        return urlencode(tmp)
Esempio n. 8
0
    def __str__(self):
        '''
        Return string representation.

        >>> str(DataContainer([(u'a','1'), (u'b', ['2','3'])]))
        'a=1&b=2&b=3'
        >>> str(DataContainer([(u'aaa', None)]))
        'aaa='
        >>> str(DataContainer([(u'aaa', '')]))
        'aaa='
        >>> str(DataContainer([(u'aaa', (None, ''))]))
        'aaa=&aaa='
        >>> import urllib
        >>> dc = DataContainer([(u'a','1'), (u'u', u'Ú-ú-Ü-ü')], 'latin1')
        >>> urllib.unquote(str(dc)).decode('latin-1') == u'a=1&u=Ú-ú-Ü-ü'
        True

        :return: string representation of the DataContainer Object.
        '''
        return enc_dec.urlencode(self, encoding=self.encoding)
Esempio n. 9
0
    def __str__(self):
        '''
        This method returns a string representation of the Form object.

        Please note that if the form has radio/select/checkboxes the
        first value will be put into the string representation and the
        others will be lost.

        @see: Unittest in test_form.py
        :return: string representation of the Form object.
        '''
        d = dict(self)
        d.update(self._submit_map)

        avoid_duplicates = (self.INPUT_TYPE_CHECKBOX, self.INPUT_TYPE_RADIO,
                            self.INPUT_TYPE_SELECT)

        for key in d:
            key_type = self._types.get(key, None)
            if key_type in avoid_duplicates:
                d[key] = d[key][:1]

        return urlencode(d, encoding=self.encoding)
Esempio n. 10
0
    def __str__(self):
        '''
        This method returns a string representation of the Form object.

        Please note that if the form has radio/select/checkboxes the
        first value will be put into the string representation and the
        others will be lost.

        @see: Unittest in test_form.py
        :return: string representation of the Form object.
        '''
        d = dict(self)
        d.update(self._submit_map)

        avoid_duplicates = (self.INPUT_TYPE_CHECKBOX, self.INPUT_TYPE_RADIO,
                            self.INPUT_TYPE_SELECT)

        for key in d:
            key_type = self._types.get(key, None)
            if key_type in avoid_duplicates:
                d[key] = d[key][:1]

        return urlencode(d, encoding=self.encoding)
Esempio n. 11
0
 def test_simple(self):
     self.assertEqual(urlencode(parse_qs(u'a=1&a=c'), 'latin1'), 'a=1&a=c')
Esempio n. 12
0
 def test_tilde_case02(self):
     self.assertEqual(urlencode(parse_qs(u'a=á&a=2'), 'utf-8'),
                      'a=%C3%A1&a=2')
Esempio n. 13
0
 def test_tilde_case01(self):
     self.assertEqual(urlencode(parse_qs(u'a=á&a=2'), 'latin1'),
                      'a=%E1&a=2')
Esempio n. 14
0
 def test_simple(self):
     self.assertEqual(urlencode(parse_qs(u"a=1&a=c"), "latin1"), "a=1&a=c")
Esempio n. 15
0
 def test_tilde_case02(self):
     self.assertEqual(urlencode(parse_qs(u"a=á&a=2"), "utf-8"), "a=%C3%A1&a=2")
Esempio n. 16
0
 def test_tilde_case01(self):
     self.assertEqual(urlencode(parse_qs(u"a=á&a=2"), "latin1"), "a=%E1&a=2")