]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
docstrings, formatting fixes
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 4 Dec 2005 20:34:21 +0000 (20:34 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 4 Dec 2005 20:34:21 +0000 (20:34 +0000)
doc/build/components/formatting.myt
doc/build/components/pydoc.myt
doc/build/content/docstrings.myt
lib/sqlalchemy/ansisql.py
lib/sqlalchemy/mapping/properties.py
lib/sqlalchemy/schema.py
lib/sqlalchemy/sql.py

index e22a7fd15b89c8038abc694653df612dbd12273c..6f92cc80899cf131f95389d62a54cff05f43cca7 100644 (file)
 <%method formatplain>
     <%filter>
         import re
-        f = re.sub(r'(.+)\n\n',r"<p>\1</p>",f, re.S)
-        f = re.sub(r'\n', r'<br/>\n', f, re.S)
+        f = re.sub(r'\n[\s\t]*\n[\s\t]*', '</p>\n<p>', f, re.S)
+        f = "<p>" + f + "</p>"
         return f
     </%filter>
 <% m.content() %>
index 5cb58628b90f0a8b76902a1e1633b18c4ec1fe49..4f0b554e001758257596dcb67a60d0fe6dc39593 100644 (file)
@@ -1,6 +1,7 @@
 <%global>
     import re
     def format_paragraphs(text):
+        return text
         return re.sub(r'([\w ])\n([\w ])', r'\1 \2', text or '', re.S)
 </%global>
 
index 24f6e52c4e358f4c7e2fdf039eab742b011e0901..4dd5aa98268e6b5ef80c6b32ebbcc8cacb8f8228 100644 (file)
@@ -12,7 +12,7 @@
 
 <& pydoc.myt:obj_doc, obj=schema &>
 <& pydoc.myt:obj_doc, obj=engine, classes=[engine.SQLEngine, engine.ResultProxy, engine.RowProxy] &>
-<& pydoc.myt:obj_doc, obj=sql &>
+<& pydoc.myt:obj_doc, obj=sql, classes=[sql.Compiled, sql.ClauseElement, sql.TableImpl, sql.ColumnImpl] &>
 <& pydoc.myt:obj_doc, obj=pool, classes=[pool.DBProxy, pool.Pool, pool.QueuePool, pool.SingletonThreadPool] &>
 <& pydoc.myt:obj_doc, obj=mapping &>
 <& pydoc.myt:obj_doc, obj=mapping.objectstore, classes=[mapping.objectstore.UnitOfWork] &>
index 2a709e3b757ab621c655d2472658364ffdf54cdb..691106a710ae9f12465b4195b096ce18ae318931 100644 (file)
@@ -284,7 +284,7 @@ class ANSICompiler(sql.Compiled):
     def visit_join(self, join):
         # TODO: ppl are going to want RIGHT, FULL OUTER and NATURAL joins.
         righttext = self.get_from_text(join.right)
-        if join.right.group_parenthesized():
+        if join.right._group_parenthesized():
             righttext = "(" + righttext + ")"
         if join.isouter:
             self.froms[join] = (self.get_from_text(join.left) + " LEFT OUTER JOIN " + righttext + 
index fdce0c0e88edab984a4026399cd55d49a2f9849e..5c037f0c552c1c6aaf8824c6c94f375609fd474b 100644 (file)
@@ -176,11 +176,11 @@ class PropertyLoader(MapperProperty):
         crit = []
         for fk in secondary.foreign_keys:
             if fk.references(primary):
-                crit.append(primary.get_col_by_original(fk.column) == fk.parent)
+                crit.append(primary._get_col_by_original(fk.column) == fk.parent)
                 self.foreignkey = fk.parent
         for fk in primary.foreign_keys:
             if fk.references(secondary):
-                crit.append(secondary.get_col_by_original(fk.column) == fk.parent)
+                crit.append(secondary._get_col_by_original(fk.column) == fk.parent)
                 self.foreignkey = fk.parent
         if len(crit) == 0:
             raise "Cant find any foreign key relationships between '%s' (%s) and '%s' (%s)" % (primary.name, repr(primary), secondary.name, repr(secondary))
@@ -588,7 +588,7 @@ class EagerLoader(PropertyLoader):
                 statement.order_by(self.eagertarget.rowid_column)
 
         if self.order_by is not None:
-            statement.order_by(*[self.eagertarget.get_col_by_original(c) for c in self.order_by])
+            statement.order_by(*[self.eagertarget._get_col_by_original(c) for c in self.order_by])
             
         statement.append_from(statement._outerjoin)
         statement.append_column(self.eagertarget)
index bebf38efed849540eba5399ff55360513d83e74a..789bb6ed8c03054cc14e7cc39de919e29787e95d 100644 (file)
@@ -87,7 +87,9 @@ class TableSingleton(type):
 
         
 class Table(SchemaItem):
-    """represents a relational database table."""
+    """represents a relational database table.  
+    
+    Be sure to look at sqlalchemy.sql.TableImpl for additional methods defined on a Table."""
     __metaclass__ = TableSingleton
     
     def __init__(self, name, engine, *args, **kwargs):
@@ -249,7 +251,7 @@ class ForeignKey(SchemaItem):
             self.column.table is table      
             or
             # test for an indirect relation via a Selectable
-            table.get_col_by_original(self.column) is not None
+            table._get_col_by_original(self.column) is not None
         )
         
     def _init_column(self):
index a5ff50900eddceeed5b79e8df6c6c7fad4849ab6..71cbacdac0f0bb78294f8c63a080f22c2c608e07 100644 (file)
@@ -54,6 +54,8 @@ def join(left, right, onclause, **kwargs):
 def select(columns=None, whereclause = None, from_obj = [], **kwargs):
     """returns a SELECT clause element.
     
+    this can also be called via the table's select() method.
+    
     'columns' is a list of columns and/or selectable items to select columns from
     'whereclause' is a text or ClauseElement expression which will form the WHERE clause
     'from_obj' is an list of additional "FROM" objects, such as Join objects, which will 
@@ -64,9 +66,12 @@ def select(columns=None, whereclause = None, from_obj = [], **kwargs):
     return Select(columns, whereclause = whereclause, from_obj = from_obj, **kwargs)
 
 def insert(table, values = None, **kwargs):
-    """returns an INSERT clause element.
+    """returns an INSERT clause element.  
+    
+    This can also be called from a table directly via the table's insert() method.
     
     'table' is the table to be inserted into.
+    
     'values' is a dictionary which specifies the column specifications of the INSERT, 
     and is optional.  If left as None, the column specifications are determined from the 
     bind parameters used during the compile phase of the INSERT statement.  If the 
@@ -84,7 +89,9 @@ def insert(table, values = None, **kwargs):
     return Insert(table, values, **kwargs)
 
 def update(table, whereclause = None, values = None, **kwargs):
-    """returns an UPDATE clause element.  
+    """returns an UPDATE clause element.   
+    
+    This can also be called from a table directly via the table's update() method.
     
     'table' is the table to be updated.
     'whereclause' is a ClauseElement describing the WHERE condition of the UPDATE statement.
@@ -107,6 +114,8 @@ def update(table, whereclause = None, values = None, **kwargs):
 def delete(table, whereclause = None, **kwargs):
     """returns a DELETE clause element.  
     
+    This can also be called from a table directly via the table's delete() method.
+    
     'table' is the table to be updated.
     'whereclause' is a ClauseElement describing the WHERE condition of the UPDATE statement.
     """
@@ -253,15 +262,7 @@ class Compiled(ClauseVisitor):
         return self.execute(*multiparams, **params).fetchone()[0]
         
 class ClauseElement(object):
-    """base class for elements of a programmatically constructed SQL expression.
-    
-    includes a list of 'from objects' which collects items to be placed
-    in the FROM clause of a SQL statement.
-    
-    when many ClauseElements are attached together, the from objects and bind
-    parameters are scooped up into the enclosing-most ClauseElement.
-    """
-
+    """base class for elements of a programmatically constructed SQL expression."""
     def hash_key(self):
         """returns a string that uniquely identifies the concept this ClauseElement
         represents.
@@ -287,6 +288,7 @@ class ClauseElement(object):
         if asfrom:
             data[self.id] = self
     def accept_visitor(self, visitor):
+        """accepts a ClauseVisitor and calls the appropriate visit_xxx method."""
         raise NotImplementedError(repr(self))
 
     def copy_container(self):
@@ -629,7 +631,7 @@ class Selectable(FromClause):
     def select(self, whereclauses = None, **params):
         return select([self], whereclauses, **params)
 
-    def get_col_by_original(self, column):
+    def _get_col_by_original(self, column):
         """given a column which is a schema.Column object attached to a schema.Table object
         (i.e. an "original" column), return the Column object from this 
         Selectable which corresponds to that original Column, or None if this Selectable
@@ -644,7 +646,7 @@ class Selectable(FromClause):
 
     def alias(self, name):
         return Alias(self, name)
-    def group_parenthesized(self):
+    def _group_parenthesized(self):
         """indicates if this Selectable requires parenthesis when grouped into a compound
         statement"""
         return True
@@ -668,12 +670,12 @@ class Join(Selectable):
         
     primary_key = property (lambda self: [c for c in self.left.columns if c.primary_key] + [c for c in self.right.columns if c.primary_key])
 
-    def group_parenthesized(self):
+    def _group_parenthesized(self):
         """indicates if this Selectable requires parenthesis when grouped into a compound
         statement"""
         return True
 
-    def get_col_by_original(self, column):
+    def _get_col_by_original(self, column):
         for c in self.columns:
             if c.original is column:
                 return c
@@ -730,7 +732,7 @@ class Alias(Selectable):
     def hash_key(self):
         return "Alias(%s, %s)" % (repr(self.selectable.hash_key()), repr(self.name))
 
-    def get_col_by_original(self, column):
+    def _get_col_by_original(self, column):
         return self.columns.get(column.key, None)
 
     def accept_visitor(self, visitor):
@@ -740,7 +742,7 @@ class Alias(Selectable):
     def _get_from_objects(self):
         return [self]
 
-    def group_parenthesized(self):
+    def _group_parenthesized(self):
         return False
         
     engine = property(lambda s: s.selectable.engine)
@@ -808,13 +810,13 @@ class ColumnImpl(Selectable, CompareMixin):
     def copy_container(self):
         return self.column
 
-    def get_col_by_original(self, column):
+    def _get_col_by_original(self, column):
         if self.column.original is column:
             return self.column
         else:
             return None
             
-    def group_parenthesized(self):
+    def _group_parenthesized(self):
         return False
         
     def _get_from_objects(self):
@@ -846,12 +848,9 @@ class TableImpl(Selectable):
     
     rowid_column = property(lambda s: s._rowid_column)
     
-    def get_from_text(self):
-        return self.table.name
-    
     engine = property(lambda s: s.table.engine)
 
-    def get_col_by_original(self, column):
+    def _get_col_by_original(self, column):
         try:
           col = self.columns[column.key]
         except KeyError:
@@ -861,7 +860,7 @@ class TableImpl(Selectable):
         else:
           return None
 
-    def group_parenthesized(self):
+    def _group_parenthesized(self):
         return False
 
     def _process_from_dict(self, data, asfrom):
@@ -1024,7 +1023,7 @@ class Select(Selectable, TailClauseMixin):
                 else:
                     co._make_proxy(self)
 
-    def get_col_by_original(self, column):
+    def _get_col_by_original(self, column):
         if self.use_labels:
             return self.columns.get(column.label,None)
         else: