diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-11 20:52:02 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-03-11 20:52:02 +0000 |
commit | 6a3c374b955299f0065356ef1de6cc0920d5382e (patch) | |
tree | 1ec2c2fddcc2d3c8b8f350fb42f86a84918c6fe1 /lib/sqlalchemy/sql_util.py | |
parent | 320cb9b75f763355ed798c80d245998ce57e21cc (diff) | |
download | sqlalchemy-6a3c374b955299f0065356ef1de6cc0920d5382e.tar.gz |
- for hackers, refactored the "visitor" system of ClauseElement and
SchemaItem so that the traversal of items is controlled by the
ClauseVisitor itself, using the method visitor.traverse(item).
accept_visitor() methods can still be called directly but will
not do any traversal of child items. ClauseElement/SchemaItem now
have a configurable get_children() method to return the collection
of child elements for each parent object. This allows the full
traversal of items to be clear and unambiguous (as well as loggable),
with an easy method of limiting a traversal (just pass flags which
are picked up by appropriate get_children() methods). [ticket:501]
- accept_schema_visitor() methods removed, replaced with
get_children(schema_visitor=True)
- various docstring/changelog cleanup/reformatting
Diffstat (limited to 'lib/sqlalchemy/sql_util.py')
-rw-r--r-- | lib/sqlalchemy/sql_util.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql_util.py b/lib/sqlalchemy/sql_util.py index 70fc85702..1d185bbc5 100644 --- a/lib/sqlalchemy/sql_util.py +++ b/lib/sqlalchemy/sql_util.py @@ -51,7 +51,7 @@ class TableCollection(object): tuples.append( ( parent_table, child_table ) ) vis = TVisitor() for table in self.tables: - table.accept_schema_visitor(vis) + vis.traverse(table) sorter = topological.QueueDependencySorter( tuples, self.tables ) head = sorter.sort() sequence = [] @@ -64,21 +64,21 @@ class TableCollection(object): return sequence -class TableFinder(TableCollection, sql.ClauseVisitor): +class TableFinder(TableCollection, sql.NoColumnVisitor): """Given a ``Clause``, locate all the ``Tables`` within it into a list.""" def __init__(self, table, check_columns=False): TableCollection.__init__(self) self.check_columns = check_columns if table is not None: - table.accept_visitor(self) + self.traverse(table) def visit_table(self, table): self.tables.append(table) def visit_column(self, column): if self.check_columns: - column.table.accept_visitor(self) + self.traverse(column.table) class ColumnFinder(sql.ClauseVisitor): def __init__(self): @@ -103,7 +103,7 @@ class ColumnsInClause(sql.ClauseVisitor): if self.selectable.c.get(column.key) is column: self.result = True -class AbstractClauseProcessor(sql.ClauseVisitor): +class AbstractClauseProcessor(sql.NoColumnVisitor): """Traverse a clause and attempt to convert the contents of container elements to a converted element. @@ -132,7 +132,7 @@ class AbstractClauseProcessor(sql.ClauseVisitor): if elem is not None: list_[i] = elem else: - list_[i].accept_visitor(self) + self.traverse(list_[i]) def visit_compound(self, compound): self.visit_clauselist(compound) @@ -198,7 +198,7 @@ class ClauseAdapter(AbstractClauseProcessor): s = table1.alias('foo') - calling ``condition.accept_visitor(ClauseAdapter(s))`` converts + calling ``ClauseAdapter(s).traverse(condition)`` converts condition to read:: s.c.col1 == table2.c.col1 |