[CalendarServer-changes] [9600] CalendarServer/branches/users/glyph/q
source_changes at macosforge.org
source_changes at macosforge.org
Sat Aug 11 01:54:41 PDT 2012
Revision: 9600
http://trac.macosforge.org/projects/calendarserver/changeset/9600
Author: glyph at apple.com
Date: 2012-08-11 01:54:41 -0700 (Sat, 11 Aug 2012)
Log Message:
-----------
Additional documentation. Allow for (explicitly-instantiated) implicit (in the database) columns to be 'in' the tables they are bound to.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/q/
Modified: CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py
===================================================================
--- CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py 2012-08-11 08:54:40 UTC (rev 9599)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/dal/syntax.py 2012-08-11 08:54:41 UTC (rev 9600)
@@ -603,7 +603,7 @@
def __contains__(self, columnSyntax):
if isinstance(columnSyntax, FunctionInvocation):
columnSyntax = columnSyntax.arg
- return (columnSyntax.model in self.model.columns)
+ return (columnSyntax.model.table is self.model)
@@ -946,17 +946,37 @@
-def _columnsMatchTables(columns, tables):
+def _checkColumnsMatchTables(columns, tables):
+ """
+ Verify that the given C{columns} match the given C{tables}; that is, that
+ every L{TableSyntax} referenced by every L{ColumnSyntax} referenced by
+ every L{ExpressionSyntax} in the given C{columns} list is present in the
+ given C{tables} list.
+
+ @param columns: a L{list} of L{ExpressionSyntax}, each of which references
+ some set of L{ColumnSyntax}es via its C{allColumns} method.
+
+ @param tables: a L{list} of L{TableSyntax}
+
+ @return: L{None}
+ @rtype: L{NoneType}
+
+ @raise TableMismatch: if any table referenced by a column is I{not} found
+ in C{tables}
+ """
for expression in columns:
for column in expression.allColumns():
for table in tables:
if column in table:
break
else:
- return False
- return True
+ raise TableMismatch("{} not found in {}".format(
+ column, tables
+ ))
+ return None
+
class Tuple(ExpressionSyntax):
def __init__(self, columns):
@@ -1065,8 +1085,7 @@
if columns is None:
columns = ALL_COLUMNS
else:
- if not _columnsMatchTables(columns, From.tables()):
- raise TableMismatch()
+ _checkColumnsMatchTables(columns, From.tables())
columns = _SomeColumns(columns)
self.columns = columns
@@ -1451,6 +1470,12 @@
class Update(_DMLStatement):
"""
'update' statement
+
+ @ivar columnMap: A L{dict} mapping L{ColumnSyntax} objects to values to
+ change; values may be simple database values (such as L{str},
+ L{unicode}, L{datetime.datetime}, L{float}, L{int} etc) or L{Parameter}
+ instances.
+ @type columnMap: L{dict}
"""
def __init__(self, columnMap, Where, Return=None):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120811/92db26f3/attachment.html>
More information about the calendarserver-changes
mailing list