Example #1
0
 def method(self, other):
     with context(UNPROXIFING_CONTEXT):
         instance = self.expression
         token = self.token
         if IQueryPart.providedBy(other):
             other = other.expression
     if not inverse:
         result = QueryPart(expression=operation(instance, other),
                            token=token)
     else:
         result = QueryPart(expression=operation(other, instance),
                            token=token)
     return result
Example #2
0
 def method(self, other):
     with context(UNPROXIFING_CONTEXT):
         instance = self.expression
         token = self.token
         if IQueryPart.providedBy(other):
             other = other.expression
     if not inverse:
         result = QueryPart(expression=operation(instance, other),
                            token=token)
     else:
         result = QueryPart(expression=operation(other, instance),
                            token=token)
     return result
Example #3
0
    def test_plain_iter(self):
        t1 = next(iter(this))
        with context(UNPROXIFING_CONTEXT):
            self.assertTrue(IQueryPart.providedBy(t1),
                                  'When itering over a this instance we '
                                  'should get an IQueryPart object')

        t1 = next(parent for parent in this('parent'))
        self.assertEquals('parent', unboxed(unboxed(t1)._expression).name,
                          'The name of the QueryBuilderToken should be '
                          'the same as the name of the actual instance')

        t1 = next(parent for parent in this('parent').children)
        self.assertEquals('children', unboxed(unboxed(t1)._expression).name,
                          'The name of the QueryBuilderToken should be '
                          'the same as the name of the actual instance')
Example #4
0
 def __iter__(self):
     from types import GeneratorType
     try:
         result = super(new_meta, self).__iter__()
     except AttributeError:
         result = Unset
     if isinstance(result, GeneratorType):
         for item in result:
             yield item
     elif result is not Unset and IQueryPart.providedBy(result):
             yield result
     elif result is Unset:
         from xotl.ql.expressions import is_instance
         query_part = next(iter(this(name)))
         is_instance(query_part, self)
         yield query_part
     else:
         raise TypeError('Class {target} has a metaclass with an '
                         '__iter__ that does not support thesefy'
                         .format(target=target))
Example #5
0
 def __iter__(self):
     from types import GeneratorType
     try:
         result = super(new_meta, self).__iter__()
     except AttributeError:
         result = Unset
     if isinstance(result, GeneratorType):
         for item in result:
             yield item
     elif result is not Unset and IQueryPart.providedBy(result):
         yield result
     elif result is Unset:
         from xotl.ql.expressions import is_instance
         query_part = next(iter(this(name)))
         is_instance(query_part, self)
         yield query_part
     else:
         raise TypeError(
             'Class {target} has a metaclass with an '
             '__iter__ that does not support thesefy'.format(
                 target=target))
Example #6
0
    def test_plain_iter(self):
        t1 = next(iter(this))
        with context(UNPROXIFING_CONTEXT):
            self.assertTrue(
                IQueryPart.providedBy(t1),
                'When itering over a this instance we '
                'should get an IQueryPart object')

        t1 = next(parent for parent in this('parent'))
        self.assertEquals(
            'parent',
            unboxed(unboxed(t1)._expression).name,
            'The name of the QueryBuilderToken should be '
            'the same as the name of the actual instance')

        t1 = next(parent for parent in this('parent').children)
        self.assertEquals(
            'children',
            unboxed(unboxed(t1)._expression).name,
            'The name of the QueryBuilderToken should be '
            'the same as the name of the actual instance')