Ejemplo n.º 1
0
 def testEscaping(self):
     l = token_split('"Roch\'e" Compaan')
     self.assertEqual(l, ["Roch'e", "Compaan"])
     l = token_split(r'hello\ world')
     self.assertEqual(l, ['hello world'])
     l = token_split(r'\\')
     self.assertEqual(l, ['\\'])
     l = token_split(r'\n')
     self.assertEqual(l, ['\n'])
Ejemplo n.º 2
0
 def testEscaping(self):
     l = token_split('"Roch\'e" Compaan')
     self.assertEqual(l, ["Roch'e", "Compaan"])
     l = token_split(r'hello\ world')
     self.assertEqual(l, ['hello world'])
     l = token_split(r'\\')
     self.assertEqual(l, ['\\'])
     l = token_split(r'\n')
     self.assertEqual(l, ['\n'])
Ejemplo n.º 3
0
    def fakeFilterVars(self):
        """Add a faked :filter form variable for each filtering prop."""
        cls = self.db.classes[self.classname]
        for key in self.form.keys():
            prop = cls.get_transitive_prop(key)
            if not prop:
                continue
            if isinstance(self.form[key], type([])):
                # search for at least one entry which is not empty
                for minifield in self.form[key]:
                    if minifield.value:
                        break
                else:
                    continue
            else:
                if not self.form[key].value:
                    continue
                if isinstance(prop, hyperdb.String):
                    v = self.form[key].value
                    l = token.token_split(v)
                    if len(l) > 1 or l[0] != v:
                        self.form.value.remove(self.form[key])
                        # replace the single value with the split list
                        for v in l:
                            self.form.value.append(cgi.MiniFieldStorage(
                                key, v))

            self.form.value.append(cgi.MiniFieldStorage('@filter', key))
Ejemplo n.º 4
0
    def fakeFilterVars(self):
        """Add a faked :filter form variable for each filtering prop."""
        cls = self.db.classes[self.classname]
        for key in self.form:
            prop = cls.get_transitive_prop(key)
            if not prop:
                continue
            if isinstance(self.form[key], type([])):
                # search for at least one entry which is not empty
                for minifield in self.form[key]:
                    if minifield.value:
                        break
                else:
                    continue
            else:
                if not self.form[key].value:
                    continue
                if isinstance(prop, hyperdb.String):
                    v = self.form[key].value
                    l = token.token_split(v)
                    if len(l) != 1 or l[0] != v:
                        self.form.value.remove(self.form[key])
                        # replace the single value with the split list
                        for v in l:
                            self.form.value.append(cgi.MiniFieldStorage(key, v))

            self.form.value.append(cgi.MiniFieldStorage('@filter', key))
Ejemplo n.º 5
0
 def testEmbedQuote(self):
     l = token_split(r'Roch\'e Compaan')
     self.assertEqual(l, ["Roch'e", "Compaan"])
     l = token_split('address="1 2 3"')
     self.assertEqual(l, ['address=1 2 3'])
Ejemplo n.º 6
0
 def testQuoting(self):
     l = token_split('"hello world"')
     self.assertEqual(l, ['hello world'])
     l = token_split("'hello world'")
     self.assertEqual(l, ['hello world'])
Ejemplo n.º 7
0
 def testIgnoreExtraSpace(self):
     l = token_split('hello  world ')
     self.assertEqual(l, ['hello', 'world'])
Ejemplo n.º 8
0
 def testValid(self):
     l = token_split('hello world')
     self.assertEqual(l, ['hello', 'world'])
Ejemplo n.º 9
0
 def testEmbedQuote(self):
     l = token_split(r'Roch\'e Compaan')
     self.assertEqual(l, ["Roch'e", "Compaan"])
     l = token_split('address="1 2 3"')
     self.assertEqual(l, ['address=1 2 3'])
Ejemplo n.º 10
0
 def testQuoting(self):
     l = token_split('"hello world"')
     self.assertEqual(l, ['hello world'])
     l = token_split("'hello world'")
     self.assertEqual(l, ['hello world'])
Ejemplo n.º 11
0
 def testIgnoreExtraSpace(self):
     l = token_split('hello  world ')
     self.assertEqual(l, ['hello', 'world'])
Ejemplo n.º 12
0
 def testValid(self):
     l = token_split('hello world')
     self.assertEqual(l, ['hello', 'world'])