Example #1
0
    def findBy(klass, **attrs):
        """
        Find all instances of the given class based on an exact match of attributes.

        For instance:
        C{User.find(first_name='Bob', last_name='Smith')}

        Will return all matches.
        """
        where = dictToWhere(attrs)
        return klass.find(where = where)
Example #2
0
    def findBy(klass, **attrs):
        """
        Find all instances of the given class based on an exact match of attributes.

        For instance:
        C{User.find(first_name='Bob', last_name='Smith')}

        Will return all matches.
        """
        where = dictToWhere(attrs)
        return klass.find(where=where)
Example #3
0
    def findBy(klass, **attrs):
        """
        Find all instances of the given class based on an exact match of attributes.

        For instance:
        C{User.find(first_name='Bob', last_name='Smith')}

        Will return all matches.
        """
        transaction = None
        if 'transaction' in attrs:
            transaction = attrs['transaction']
            del(attrs['transaction'])
        where = dictToWhere(attrs)
        return klass.find(where = where, transaction=transaction)
Example #4
0
    def findBy(klass, **attrs):
        """
        Find all instances of the given class based on an exact match of attributes.

        For instance:
        C{User.find(first_name='Bob', last_name='Smith')}

        Will return all matches.
        """
        transaction = None
        if 'transaction' in attrs:
            transaction = attrs['transaction']
            del(attrs['transaction'])
        where = dictToWhere(attrs)
        return klass.find(where = where, transaction=transaction)
Example #5
0
    def test_dictToWhere(self):
        self.assertEqual(utils.dictToWhere({}), None)

        result = utils.dictToWhere({ 'one': 'two' }, "BLAH")
        self.assertEqual(result, ["(one = ?)", "two"])

        result = utils.dictToWhere({ 'one': None }, "BLAH")
        self.assertEqual(result, ["(one is ?)", None])

        result = utils.dictToWhere({ 'one': 'two', 'three': 'four' })
        self.assertEqual(result, ["(three = ?) AND (one = ?)", "four", "two"])

        result = utils.dictToWhere({ 'one': 'two', 'three': 'four', 'five': 'six' }, "BLAH")
        self.assertEqual(result, ["(five = ?) BLAH (three = ?) BLAH (one = ?)", "six", "four", "two"])

        result = utils.dictToWhere({ 'one': 'two', 'three': None })
        self.assertEqual(result, ["(three is ?) AND (one = ?)", None, "two"])
Example #6
0
    def test_dictToWhere(self):
        self.assertEqual(utils.dictToWhere({}), None)

        result = utils.dictToWhere({'one': 'two'}, "BLAH")
        self.assertEqual(result, ["(one = ?)", "two"])

        result = utils.dictToWhere({'one': None}, "BLAH")
        self.assertEqual(result, ["(one is ?)", None])

        result = utils.dictToWhere(OrderedDict([
            ('one', 'two'), ('three', 'four')]))
        self.assertEqual(result, ["(one = ?) AND (three = ?)", "two", "four"])

        result = utils.dictToWhere(OrderedDict([
            ('one', 'two'), ('three', 'four'), ('five', 'six')]), "BLAH")
        self.assertEqual(result, ["(one = ?) BLAH (three = ?) BLAH (five = ?)", "two", "four", "six"])

        result = utils.dictToWhere(OrderedDict([
            ('one', 'two'), ('three', None)]))
        self.assertEqual(result, ["(one = ?) AND (three is ?)", "two", None])
Example #7
0
    def test_dictToWhere(self):
        self.assertEqual(utils.dictToWhere({}), None)

        result = utils.dictToWhere({'one': 'two'}, "BLAH")
        self.assertEqual(result, ["(one = ?)", "two"])

        result = utils.dictToWhere({'one': None}, "BLAH")
        self.assertEqual(result, ["(one is ?)", None])

        result = utils.dictToWhere(
            OrderedDict([('one', 'two'), ('three', 'four')]))
        self.assertEqual(result, ["(one = ?) AND (three = ?)", "two", "four"])

        result = utils.dictToWhere(
            OrderedDict([('one', 'two'), ('three', 'four'), ('five', 'six')]),
            "BLAH")
        self.assertEqual(result, [
            "(one = ?) BLAH (three = ?) BLAH (five = ?)", "two", "four", "six"
        ])

        result = utils.dictToWhere(
            OrderedDict([('one', 'two'), ('three', None)]))
        self.assertEqual(result, ["(one = ?) AND (three is ?)", "two", None])