Home | Trees | Index | Help |
|
---|
Package twisted :: Package enterprise :: Module sqlreflector :: Class SQLReflector |
|
Augmentation
--+ |Reflector
--+ | SQLReflector
I reflect on a database and load RowObjects from it.
In order to do this, I interrogate a relational database to extract schema information and interface with RowObject class objects that can interact with specific tables.Method Summary | |
---|---|
Initialize me against a database. | |
Implement me to populate schema information for the reflector. | |
Construct all the SQL templates for database operations on <tableName> and populate the class <rowClass> with that info. | |
immediate loading of rowobjects from the table with the whereClause. | |
Used to construct the row classes in a single interaction. | |
Build the SQL template to delete a row from the table. | |
(Internal) Build SQL template to insert a new row. | |
(Internal) Build SQL template to update a RowObject. | |
Delete the row for rowObject from the database. | |
Build SQL to delete rowObject from the database. | |
Escape a string for use in an SQL statement. | |
findTypeFor(self,
tableName,
columnName)
| |
Insert a new row for rowObject. | |
Build SQL to insert the contents of rowObject. | |
Load a set of RowObjects from a database. | |
Format a value for use in an SQL statement. | |
Update the contents of rowObject to the database. | |
Build SQL to update the contents of rowObject. | |
Inherited from Reflector | |
| |
| |
NOTE: Should this be recursive?! requires better container knowledge... | |
util method used by reflectors. | |
util method used by reflectors. | |
| |
Get a TableInfo record about a particular instance. | |
This is called once for each registered rowClass to add it and its foreign key relationships for that rowClass to the schema. | |
NOTE: should this be recursive!?? | |
Inherited from Augmentation | |
| |
Example callback for database operation success. | |
Example callback for database operation failure. | |
| |
| |
| |
| |
|
Class Variable Summary | |
---|---|
dict |
conditionalLabels = {0: '=', 1: '<', 2: '>', 3: 'like'}
|
int |
populated = 0 |
Inherited from Augmentation | |
str |
schema = ' Insert your SQL database schema here. '
|
Method Details |
---|
__init__(self,
dbpool,
rowClasses)
Initialize me against a database.
|
_populate(self)Implement me to populate schema information for the reflector.
|
_populateSchemaFor(self, rc)Construct all the SQL templates for database operations on <tableName> and populate the class <rowClass> with that info. |
_rowLoader(self, transaction, tableName, parentRow, data, whereClause, forceChildren)immediate loading of rowobjects from the table with the whereClause. |
_transPopulateSchema(self)Used to construct the row classes in a single interaction. |
buildDeleteSQL(self, tableInfo)Build the SQL template to delete a row from the table. |
buildInsertSQL(self, tableInfo)(Internal) Build SQL template to insert a new row. Returns: SQL that is used to insert a new row for a rowObject instance not created from the database. |
buildUpdateSQL(self, tableInfo)(Internal) Build SQL template to update a RowObject. Returns: SQL that is used to contruct a rowObject class. |
deleteRow(self, rowObject)Delete the row for rowObject from the database. |
deleteRowSQL(self, rowObject)Build SQL to delete rowObject from the database. |
escape_string(self, text)Escape a string for use in an SQL statement. The default implementation escapes ' with '' and \ with \. Redefine this function in a subclass if your database server uses different escaping rules. |
insertRow(self, rowObject)Insert a new row for rowObject. |
insertRowSQL(self, rowObject)Build SQL to insert the contents of rowObject. |
loadObjectsFrom(self, tableName, parentRow=None, data=None, whereClause=None, forceChildren=0)Load a set of RowObjects from a database. Create a set of python objects of <rowClass> from the contents of a table populated with appropriate data members. Example:| class EmployeeRow(row.RowObject): | pass | | def gotEmployees(employees): | for emp in employees: | emp.manager = "fred smith" | manager.updateRow(emp) | | reflector.loadObjectsFrom("employee", | data = userData, | whereClause = [("manager" , EQUAL, "fred smith")] | ).addCallback(gotEmployees)NOTE: the objects and all children should be loaded in a single transaction. NOTE: can specify a parentRow _OR_ a whereClause. |
quote_value(self, value, type)Format a value for use in an SQL statement.
|
updateRow(self, rowObject)Update the contents of rowObject to the database. |
updateRowSQL(self, rowObject)Build SQL to update the contents of rowObject. |
Class Variable Details |
---|
conditionalLabels
|
populated
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.0 on Sat May 15 20:07:55 2004 | http://epydoc.sf.net |