[SQL-CVS] r4059 - in SQLObject/trunk: . docs
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2009-12-14 19:53:13
|
Author: phd Date: 2009-12-14 12:23:26 -0700 (Mon, 14 Dec 2009) New Revision: 4059 Removed: SQLObject/trunk/docs/sqlobject-architecture.txt Modified: SQLObject/trunk/docs/FAQ.txt SQLObject/trunk/docs/index.txt SQLObject/trunk/docs/rebuild SQLObject/trunk/setup.cfg Log: Moved text from sqlobject-architecture.txt to the FAQ; removed sqlobject-architecture.txt. Modified: SQLObject/trunk/docs/FAQ.txt =================================================================== --- SQLObject/trunk/docs/FAQ.txt 2009-11-08 00:08:13 UTC (rev 4058) +++ SQLObject/trunk/docs/FAQ.txt 2009-12-14 19:23:26 UTC (rev 4059) @@ -4,6 +4,48 @@ .. contents:: +SQLExpression +------------- + +In `SomeTable.select(SomeTable.q.Foo > 30)` why doesn't the inner parameter, +`SomeTable.q.Foo > 30`, get evaluated to some boolean value? + +`q` is an object that returns special attributes of type +`sqlbuilder.SQLExpression`. SQLExpression is a special class that overrides +almost all Python magic methods and upon any operation instead of +evaluating it constructs another instance of SQLExpression that remembers +what operation it has to do. Similar to a symbolic algebra. Example: + + SQLExpression("foo") > 30 + +produces SQLExpression("foo", ">", 30) (well, it really produces +SQLExpression(SQLExpression("foo")...)) + +How does the select(...) method know what to do? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In short, select() recursively evaluates the top-most SQLExpression to a +string: + + SQLExpression("foo", ">", 30) => "foo > 30" + +and passes the result as a string to the SQL backend. + +The longer but more detailed and correct explanation is that select() +produces an instance of SelectResults_ class that upon being iterated over +produces an instance of Iteration class that upon calling its next() +method (it is iterator!) construct the SQL query string, passes it to the +backend, fetches the results, wraps every row as SQLObject instance and +passes them back to the user. + +.. _SelectResults: SelectResults.html + +For the details of the implementation see sqlobject/main.py for SQLObject, +sqlobject/sqlbuilder.py for SQLExpression, sqlobject/dbconnection.py for +DBConnection class (that constructs the query strings) and Iteration class, +and different subdirectories of sqlobject for concrete implementations of +connection classes - different backends require different query strings. + Why there is no __len__? ------------------------ Modified: SQLObject/trunk/docs/index.txt =================================================================== --- SQLObject/trunk/docs/index.txt 2009-11-08 00:08:13 UTC (rev 4058) +++ SQLObject/trunk/docs/index.txt 2009-12-14 19:23:26 UTC (rev 4059) @@ -22,7 +22,6 @@ * `Frequently Asked Questions <FAQ.html>`_ * `sqlbuilder documentation <SQLBuilder.html>`_ * `select() and SelectResults <SelectResults.html>`_ -* `A brief description of SQLObject architecture <sqlobject-architecture.html>`_ * `sqlobject-admin documentation <sqlobject-admin.html>`_ * `Inheritance <Inheritance.html>`_ * `Versioning <Versioning.html>`_ Modified: SQLObject/trunk/docs/rebuild =================================================================== --- SQLObject/trunk/docs/rebuild 2009-11-08 00:08:13 UTC (rev 4058) +++ SQLObject/trunk/docs/rebuild 2009-12-14 19:23:26 UTC (rev 4059) @@ -7,7 +7,7 @@ NORMAL="Authors DeveloperGuide FAQ Inheritance News SQLBuilder SQLObject SelectResults TODO Versioning Views - community download index links sqlobject-admin sqlobject-architecture" + community download index links sqlobject-admin" for NAME in $NORMAL ; do if [ -e "$NAME.html" -a ! "$NAME.html" -ot "$NAME.txt" ] ; then Deleted: SQLObject/trunk/docs/sqlobject-architecture.txt =================================================================== --- SQLObject/trunk/docs/sqlobject-architecture.txt 2009-11-08 00:08:13 UTC (rev 4058) +++ SQLObject/trunk/docs/sqlobject-architecture.txt 2009-12-14 19:23:26 UTC (rev 4059) @@ -1,44 +0,0 @@ -| > SomeTable.select(SomeTable.q.Foo > 30) -| > -| > Why doesn't the inner parameter, SomeTable.q.Foo > 30, get evaluated to some boolean value? - -.q is an object that returns special attributes of type -sqlbuilder.SQLExpression. SQLExpression is a special class that overrides -almost all Python magic methods and upon any operation instead of -evaluating it constructs another instance of SQLExpression that remembers -what operation it has to do. A kind of symbolic algebra. Example: - - SQLExpression("foo") > 30 - -produces SQLExpression("foo", ">", 30) (well, it really produces -SQLExpression(SQLExpression("foo")...)) - -| > How does the select(...) method know what to do? - -In short, .select() recursively evaluates the top-most SQLExpression to a -string: - - SQLExpression("foo", ">", 30) => "foo > 30" - -and passes the result as a string to the SQL backend. - -The longer but more detailed and correct explanation is that .select() -produces an instance of SelectResults class that upon being iterated over -produces an instance of Iteration class that upon calling its .next() -method (it is iterator!) construct the SQL query string, passes it to the -backend, fetches the results, wraps every row as SQLObject instance and -passes them back to the user. - -For the details of the implementation see sqlobject/main.py for SQLObject, -sqlobject/sqlbuilder.py for SQLExpression, sqlobject/dbconnection.py for -DBConnection class (that constructs the query strings) and Iteration class, -and different subdirectories of sqlobject for concrete implementations of -connection classes - different backends require different query strings. - -.. image:: http://sflogo.sourceforge.net/sflogo.php?group_id=74338&type=10 - :target: http://sourceforge.net/projects/sqlobject - :class: noborder - :align: center - :height: 15 - :width: 80 - :alt: Get SQLObject at SourceForge.net. Fast, secure and Free Open Source software downloads Modified: SQLObject/trunk/setup.cfg =================================================================== --- SQLObject/trunk/setup.cfg 2009-11-08 00:08:13 UTC (rev 4058) +++ SQLObject/trunk/setup.cfg 2009-12-14 19:23:26 UTC (rev 4059) @@ -15,7 +15,7 @@ docs/Inheritance.txt docs/News.txt docs/SQLBuilder.txt docs/SQLObject.txt docs/SelectResults.txt docs/TODO.txt docs/Versioning.txt docs/Views.txt docs/community.txt docs/download.txt - docs/links.txt docs/sqlobject-admin.txt docs/sqlobject-architecture.txt + docs/links.txt docs/sqlobject-admin.txt doc_base = docs/ dest = docs/html modules = sqlobject |