Django

Code

Changeset 6866

Show
Ignore:
Timestamp:
12/03/07 15:10:41 (11 months ago)
Author:
mtredinnick
Message:

queryset-refactor: Changed all tree and filter "connections" to "connectors" so
that database connections and constraint connectors look different in the code.
George Vilches pointed out this was slightly confusing previously.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/django/db/models/sql/query.py

    r6860 r6866  
    258258        return ' '.join(result), tuple(params) 
    259259 
    260     def combine(self, rhs, connection): 
     260    def combine(self, rhs, connector): 
    261261        """ 
    262262        Merge the 'rhs' query into the current one (with any 'rhs' effects 
     
    264264        current query. 'rhs' is not modified during a call to this function. 
    265265 
    266         The 'connection' parameter describes how to connect filters from the 
     266        The 'connector' parameter describes how to connect filters from the 
    267267        'rhs' query. 
    268268        """ 
     
    277277        change_map = {} 
    278278        used = {} 
    279         conjunction = (connection == AND) 
     279        conjunction = (connector == AND) 
    280280        first = True 
    281281        for alias in rhs.tables: 
     
    322322        else: 
    323323            w = WhereNode() 
    324         self.where.add(w, connection
     324        self.where.add(w, connector
    325325 
    326326        # Selection columns and extra extensions are those provided by 'rhs'. 
     
    466466        for field in ordering: 
    467467            if field == '?': 
    468                 result.append(self.connection.ops.random_function_sql()) 
     468                result.append(self.connector.ops.random_function_sql()) 
    469469                continue 
    470470            if isinstance(field, int): 
     
    665665                    used) 
    666666 
    667     def add_filter(self, filter_expr, connection=AND, negate=False): 
     667    def add_filter(self, filter_expr, connector=AND, negate=False): 
    668668        """ 
    669669        Add a single filter to the query. 
     
    695695        try: 
    696696            field, target, unused, join_list, nullable = self.setup_joins(parts, 
    697                     opts, alias, (connection == AND)) 
     697                    opts, alias, (connector == AND)) 
    698698        except TypeError, e: 
    699699            if len(parts) != 1 or parts[0] not in self.extra_select: 
     
    701701            # Filtering on some alias from extra(select=...) 
    702702            self.where.add([None, parts[0], None, lookup_type, value], 
    703                     connection
     703                    connector
    704704            return 
    705705        col = target.column 
     
    725725            self.promote_alias(join_list[-1][0]) 
    726726 
    727         self.where.add([alias, col, field, lookup_type, value], connection
     727        self.where.add([alias, col, field, lookup_type, value], connector
    728728        if negate: 
    729729            flag = False 
     
    751751        for child in q_object.children: 
    752752            if isinstance(child, Node): 
    753                 self.where.start_subtree(q_object.connection
     753                self.where.start_subtree(q_object.connector
    754754                self.add_q(child) 
    755755                self.where.end_subtree() 
    756756            else: 
    757                 self.add_filter(child, q_object.connection, q_object.negated) 
     757                self.add_filter(child, q_object.connector, q_object.negated) 
    758758 
    759759    def setup_joins(self, names, opts, alias, dupe_multis): 
  • django/branches/queryset-refactor/django/db/models/sql/where.py

    r6762 r6866  
    5858                    format = '%s' 
    5959                except EmptyResultSet: 
    60                     if self.connection == AND and not node.negated: 
     60                    if self.connector == AND and not node.negated: 
    6161                        # We can bail out early in this particular case (only). 
    6262                        raise 
     
    6565                result.append(format % sql) 
    6666                result_params.extend(params) 
    67         conn = ' %s ' % node.connection 
     67        conn = ' %s ' % node.connector 
    6868        return conn.join(result), result_params 
    6969 
  • django/branches/queryset-refactor/django/utils/tree.py

    r6493 r6866  
    1212    Node instances. 
    1313    """ 
    14     # Standard connection type. Clients usually won't use this at all and 
     14    # Standard connector type. Clients usually won't use this at all and 
    1515    # subclasses will usually override the value. 
    1616    default = 'DEFAULT' 
    1717 
    18     def __init__(self, children=None, connection=None): 
     18    def __init__(self, children=None, connector=None): 
    1919        self.children = children and children[:] or [] 
    20         self.connection = connection or self.default 
     20        self.connector = connector or self.default 
    2121        self.subtree_parents = [] 
    2222        self.negated = False 
    2323 
    2424    def __str__(self): 
    25         return '(%s: %s)' % (self.connection, ', '.join([str(c) for c in 
     25        return '(%s: %s)' % (self.connector, ', '.join([str(c) for c in 
    2626            self.children])) 
    2727 
     
    3030        Utility method used by copy.deepcopy(). 
    3131        """ 
    32         obj = self.__class__(connection=self.connection
     32        obj = self.__class__(connector=self.connector
    3333        obj.children = copy.deepcopy(self.children, memodict) 
    3434        obj.subtree_parents = copy.deepcopy(self.subtree_parents, memodict) 
     
    5757        """ 
    5858        Adds a new node to the tree. If the conn_type is the same as the root's 
    59         current connection type, the node is added to the first level. 
     59        current connector type, the node is added to the first level. 
    6060        Otherwise, the whole tree is pushed down one level and a new root 
    61         connection is created, connecting the existing tree and the new node. 
     61        connector is created, connecting the existing tree and the new node. 
    6262        """ 
    6363        if len(self.children) < 2: 
    64             self.connection = conn_type 
    65         if self.connection == conn_type: 
    66             if isinstance(node, Node) and (node.connection == conn_type 
     64            self.connector = conn_type 
     65        if self.connector == conn_type: 
     66            if isinstance(node, Node) and (node.connector == conn_type 
    6767                    or len(node) == 1): 
    6868                self.children.extend(node.children) 
     
    7070                self.children.append(node) 
    7171        else: 
    72             obj = Node(self.children, self.connection
    73             self.connection = conn_type 
     72            obj = Node(self.children, self.connector
     73            self.connector = conn_type 
    7474            self.children = [obj, node] 
    7575 
    7676    def negate(self): 
    7777        """ 
    78         Negate the sense of the root connection
     78        Negate the sense of the root connector
    7979 
    8080        Interpreting the meaning of this negate is up to client code. This 
    8181        method is useful for implementing "not" arrangements. 
    8282        """ 
    83         self.children = [NegatedNode(self.children, self.connection
     83        self.children = [NegatedNode(self.children, self.connector
    8484                old_state=self.negated)] 
    85         self.connection = self.default 
     85        self.connector = self.default 
    8686 
    8787    def start_subtree(self, conn_type): 
     
    9292        """ 
    9393        if len(self.children) == 1: 
    94             self.connection = conn_type 
    95         elif self.connection != conn_type: 
    96             self.children = [Node(self.children, self.connection)] 
    97             self.connection = conn_type 
     94            self.connector = conn_type 
     95        elif self.connector != conn_type: 
     96            self.children = [Node(self.children, self.connector)] 
     97            self.connector = conn_type 
    9898 
    99         self.subtree_parents.append(Node(self.children, self.connection)) 
    100         self.connection = self.default 
     99        self.subtree_parents.append(Node(self.children, self.connector)) 
     100        self.connector = self.default 
    101101        self.children = [] 
    102102 
     
    109109        """ 
    110110        obj = self.subtree_parents.pop() 
    111         node = Node(self.children, self.connection
    112         self.connection = obj.connection 
     111        node = Node(self.children, self.connector
     112        self.connector = obj.connector 
    113113        self.children = obj.children 
    114114        self.children.append(node) 
     
    116116class NegatedNode(Node): 
    117117    """ 
    118     A class that indicates the connection type should be negated (whatever that 
     118    A class that indicates the connector type should be negated (whatever that 
    119119    means -- it's up to the client) when used by the client code. 
    120120    """ 
    121     def __init__(self, children=None, connection=None, old_state=True): 
    122         super(NegatedNode, self).__init__(children, connection
     121    def __init__(self, children=None, connector=None, old_state=True): 
     122        super(NegatedNode, self).__init__(children, connector
    123123        self.negated = not old_state 
    124124