#NEWLINE# def where_as_ldap( self ) : #NEWLINE# #INDENT# bits = [ ] #NEWLINE# for item in self . children : #NEWLINE# #INDENT# if ( hasattr ( item , 'lhs' ) and hasattr ( item , 'rhs' ) ) : #NEWLINE# #INDENT# item = ( item . lhs . target . column , item . lookup_name , None , item . rhs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( item , 'as_sql' ) : #NEWLINE# #INDENT# ( sql , params ) = where_as_ldap ( item ) #NEWLINE# bits . append ( sql ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# ( constraint , lookup_type , y , values ) = item #NEWLINE# if hasattr ( constraint , 'col' ) : #NEWLINE# #INDENT# constraint = constraint . col #NEWLINE# #UNINDENT# comp = get_lookup_operator ( lookup_type ) #NEWLINE# if ( lookup_type == 'in' ) : #NEWLINE# #INDENT# equal_bits = [ ( '(%s%s%s)' % ( constraint , comp , value ) ) for value in values ] #NEWLINE# clause = ( '(|%s)' % '' . join ( equal_bits ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# clause = ( '(%s%s%s)' % ( constraint , comp , equal_bits ) ) #NEWLINE# #UNINDENT# bits . append ( clause ) #NEWLINE# #UNINDENT# if ( not len ( bits ) ) : #NEWLINE# #INDENT# return ( '' , [ ] ) #NEWLINE# #UNINDENT# if ( len ( bits ) == 1 ) : #NEWLINE# #INDENT# sql_string = bits [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . connector == AND ) : #NEWLINE# #INDENT# sql_string = ( '(&%s)' % '' . join ( bits ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . connector == OR ) : #NEWLINE# #INDENT# sql_string = ( '(|%s)' % '' . join ( bits ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise Exception ( ( 'Unhandled WHERE connector: %s' % self . connector ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . negated : #NEWLINE# #INDENT# sql_string = ( '(!%s)' % sql_string ) #NEWLINE# #UNINDENT# return ( sql_string , [ ] )