class ZMSSqlDb(zmscustom.ZMSCustom): (source)
Custom ZMS content type that exposes relational database backed records.
| Method | ajax |
Return matching entity column names for autocomplete widgets. |
| Method | ajax |
Return autocomplete option labels for a configured entity column. |
| Method | assemble |
Normalize a database query result into ZMS column and record structures. |
| Method | assemble |
Assemble the SQL filter expression for a where clause. |
| Method | commit |
Commit the current database transaction. |
| Method | delete |
Delete a blob after authorizing the remote caller. |
| Method | execute |
Execute an SQL statement using the configured database adapter. |
| Method | execute |
Execute an SQL modifying statement and return the affected row count. |
| Method | filtered |
Return an empty list because SQL database objects do not expose child nodes. |
| Method | get |
Return the raw data payload of a stored blob. |
| Method | get |
Return the configured database adapter object. |
| Method | get |
Retrieve and process a comprehensive list of entity descriptors from the database. |
| Method | get |
Return a list of entity descriptors by reflecting the database schema via SQLAlchemy. |
| Method | get |
Return an entity descriptor with metadata and columns for a given table. |
| Method | get |
Return a column descriptor with metadata and value for a given table column. |
| Method | get |
Build the full rendering context for manage_zmi_details_grid. |
| Method | get |
Return the primary-key column name of an entity. |
| Method | get |
Build a helper that post-processes rows for export and display. |
| Method | get |
Resolve the effective target entity for relation-like stereotypes. |
| Method | get |
Resolve or create a referenced row for a foreign-key relation. |
| Method | get |
Return the parsed SQL model and refresh the cached copy when needed. |
| Method | get |
Return the Zope object that stores the serialized SQL model definition. |
| Method | manage_change |
Update SQL entity configuration and field metadata from the management UI. |
| Method | manage_change |
Persist SQL database properties and the serialized model definition. |
| Method | query |
Execute a select statement and normalize the result for ZMS forms. |
| Method | record |
Decode byte values in a database row according to the given encoding. |
| Method | record |
Delete a row from the selected record-set table. |
| Method | record |
Apply persisted and submitted filters to the current record-set query. |
| Method | record |
Initialize record-set request state for listing and filtering. |
| Method | record |
Insert a new row into the selected record-set table. |
| Method | record |
Build the base select statement for a record-set query. |
| Method | record |
Apply order-by clauses to the current record-set query. |
| Method | record |
Update an existing row in the selected record-set table. |
| Method | record |
Synchronize intersection tables for multi-select style columns. |
| Method | rollback |
Roll back the current database transaction. |
| Method | set |
Store a blob payload after authorizing the remote caller. |
| Method | set |
Replace the persisted SQL model definition. |
| Method | sql |
Quote a value according to the declared type of a table column. |
| Method | substitute |
Substitute positional parameter markers with quoted SQL literals. |
| Class Variable | __ac |
Undocumented |
| Class Variable | __administrator |
Undocumented |
| Class Variable | __author |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | manage |
Undocumented |
| Class Variable | meta |
Undocumented |
| Class Variable | meta |
Undocumented |
| Class Variable | security |
Undocumented |
| Class Variable | valid |
Undocumented |
| Instance Variable | charset |
Undocumented |
| Instance Variable | connection |
Undocumented |
| Instance Variable | model |
Undocumented |
| Instance Variable | model |
Undocumented |
| Instance Variable | table |
Undocumented |
| Method | _delete |
Delete the file referenced by a blob column and return its replacement value. |
| Method | _get |
Load a blob from the filesystem and return it as a ZMS file object. |
| Method | _set |
Store blob data on the server filesystem and return the stored filename. |
Return matching entity column names for autocomplete widgets.
| Parameters | |
| table | Entity name. |
| fmt:str | Optional output format, e.g. 'json'. |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Current request containing filter values. |
| Returns | |
| str | Plain-text or JSON encoded column list. |
Return autocomplete option labels for a configured entity column.
| Parameters | |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Current request containing entity, column, and filter values. |
| Returns | |
| str | Plain-text or JSON encoded option list. |
Normalize a database query result into ZMS column and record structures.
| Parameters | |
| res:object | Raw adapter result. |
| encoding:str | Optional text encoding applied to byte columns. |
| Returns | |
| dict | Dictionary with columns and records lists. |
Assemble the SQL filter expression for a where clause.
| Parameters | |
| l:list | Filter descriptors for columns and operators. |
| Returns | |
| str | SQL expression joined with AND. |
Commit the current database transaction.
Makes all changes made since the previous commit or rollback permanent and releases the database locks currently held by the connection object.
Delete a blob after authorizing the remote caller.
| Parameters | |
| auth | User id to authorize. |
| tablename:str | Entity name. |
| id:str | Blob column id. |
| rowid:object | Primary-key value of the affected row. |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Optional request context. |
| RESPONSE:ZPublisher.HTTPResponse.HTTPResponse | Optional response context. |
| Returns | |
| object | Replacement value returned by _delete_blob. |
Execute an SQL statement using the configured database adapter.
Supports parameter markers of the Python DB API.
| Parameters | |
| sql:str | SQL statement. |
| params:tuple | Values for the parameter markers. |
| max | Maximum number of rows to return, or 0 for unlimited. |
| encoding:str | Optional text encoding applied to byte columns. |
| Returns | |
| object | Raw or normalized query result depending on the adapter. |
Execute an SQL modifying statement and return the affected row count.
| Parameters | |
| sql:str | SQL modification statement. |
| Returns | |
| int | Number of affected rows. |
Return an empty list because SQL database objects do not expose child nodes.
| Parameters | |
| REQUEST:dict | Optional request context. |
| meta | Ignored meta-type selector. |
| Returns | |
| list | Always an empty list. |
Return the raw data payload of a stored blob.
| Parameters | |
| tablename:str | Entity name. |
| id:str | Blob column id. |
| rowid:object | Primary-key value of the affected row. |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Optional request context. |
| RESPONSE:ZPublisher.HTTPResponse.HTTPResponse | Optional response used to set headers. |
| Returns | |
| bytes | Raw blob data. |
Return the configured database adapter object.
| Returns | |
| object | Database adapter referenced by connection_id, or None. |
Retrieve and process a comprehensive list of entity descriptors from the database.
This method performs the following operations:
- Attempts to return a cached result from the HTTP request buffer
- Fetches entities from custom connection-specific methods (if defined)
- Falls back to SQLAlchemy-based entity retrieval if available
- Builds entities from database table browsers with column metadata
- Merges custom entities and properties from the data model configuration
- Applies sorting and default values to all entities and columns
- Caches and returns the final entity list
The method handles multiple database connection types (SQLite, Oracle, etc.) and parses column type information from database descriptions. It supports custom entity definitions through model configuration files and merges database-introspected data with user-defined model properties.
| Returns | |
| list of dict | List of entity descriptors, each containing:
|
Return a list of entity descriptors by reflecting the database schema via SQLAlchemy.
| Returns | |
| list | List of entity descriptors. |
Return an entity descriptor with metadata and columns for a given table.
| Parameters | |
| table | Entity name. |
| Returns | |
| dict | Entity descriptor with metadata and columns. |
Return a column descriptor with metadata and value for a given table column.
| Parameters | |
| table | Entity name. |
| column | Column name. |
| row:dict | Optional row data for value extraction. |
| Returns | |
| dict | Column descriptor with metadata and value. |
Build the full rendering context for manage_zmi_details_grid.
This moves detail-grid preparation logic from TAL into Python so the template focuses on markup only.
| Parameters | |
| request:ZPublisher.HTTPRequest.HTTPRequest | Current request. |
| Returns | |
| dict | Context dictionary used by zmi_details_grid.zpt. |
Return the primary-key column name of an entity.
| Parameters | |
| table | Entity name. |
| Returns | |
| str | Primary-key column identifier. |
Build a helper that post-processes rows for export and display.
| Parameters | |
| table | Entity name. |
| stereotypes:list | Column stereotypes to keep or resolve. |
| col | Optional whitelist of exported column names. |
| Returns | |
| object | Record handler instance. |
Resolve the effective target entity for relation-like stereotypes.
If the referenced entity is an intersection table, return the opposite foreign-key target. Otherwise return the referenced entity itself.
| Parameters | |
| source | Source entity name. |
| target | Referenced entity or intersection table name. |
| Returns | |
| dict | Resolved target entity descriptor. |
Resolve or create a referenced row for a foreign-key relation.
| Parameters | |
| tablename:str | Name of the SQL table. |
| id:str | Foreign-key column id. |
| name:str | Display column used for lookup. |
| value:object | Submitted foreign-key value. |
| create | Create a new referenced row when no match exists. |
| Returns | |
| int | Referenced row id. |
Return the parsed SQL model and refresh the cached copy when needed.
| Returns | |
| list | Parsed SQL model definition. |
Return the Zope object that stores the serialized SQL model definition.
| Returns | |
| object | DTML method containing the SQL model XML. |
Update SQL entity configuration and field metadata from the management UI.
| Parameters | |
| lang:str | Active language. |
| btn:str | Submitted action button id. |
| key:str | Configuration subsection to update. |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Current request containing submitted configuration values. |
| RESPONSE:ZPublisher.HTTPResponse.HTTPResponse | Response used for redirect handling. |
| Returns | |
| object | Redirect response back to the configuration form. |
Persist SQL database properties and the serialized model definition.
| Parameters | |
| lang:str | Active language. |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Current request containing form values. |
| RESPONSE:ZPublisher.HTTPResponse.HTTPResponse | Response used for redirect handling. |
| Returns | |
| object | Redirect response to the properties form. |
Execute a select statement and normalize the result for ZMS forms.
| Parameters | |
| sql:str | Select statement. |
| max | Maximum number of rows to return, or 0 for unlimited. |
| encoding:str | Optional text encoding applied to byte columns. |
| Returns | |
| dict | Dictionary with columns and records lists. |
Decode byte values in a database row according to the given encoding.
| Parameters | |
| cols:list | Column descriptors for the row. |
| record:dict | Raw database record. |
| encoding:str | Text encoding used for byte strings. |
| Returns | |
| dict | Normalized row dictionary. |
Delete a row from the selected record-set table.
| Parameters | |
| tablename:str | Name of the SQL table. |
| rowid:object | Primary-key value of the row to delete. |
Apply persisted and submitted filters to the current record-set query.
| Parameters | |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Triggering request. |
Initialize record-set request state for listing and filtering.
| Parameters | |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Triggering request. |
Insert a new row into the selected record-set table.
| Parameters | |
| tablename:str | Name of the SQL table. |
| values:dict | Column values to insert. |
| update | Update related intersection tables afterwards. |
| Returns | |
| object | Primary-key value of the inserted row. |
Build the base select statement for a record-set query.
| Parameters | |
| tablename:str | Entity name. |
| select:str | Optional explicit select clause. |
| where:str | Optional initial where clause. |
| Returns | |
| str | SQL select statement. |
Apply order-by clauses to the current record-set query.
| Parameters | |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Triggering request. |
Update an existing row in the selected record-set table.
| Parameters | |
| tablename:str | Name of the SQL table. |
| rowid:object | Primary-key value of the row to update. |
| values:dict | New column values. |
| old | Optional previous values used for change detection. |
| update | Update related intersection tables afterwards. |
| Returns | |
| object | Primary-key value of the updated row. |
Synchronize intersection tables for multi-select style columns.
| Parameters | |
| tablename:str | Name of the SQL table. |
| rowid:object | Primary-key value of the parent row. |
| values:dict | Submitted column values. |
Roll back the current database transaction.
Undo all changes made in the current transaction and release the database locks currently held by the connection object.
Store a blob payload after authorizing the remote caller.
| Parameters | |
| auth | User id to authorize. |
| tablename:str | Entity name. |
| id:str | Blob column id. |
| rowid:object | Optional primary-key value of the affected row. |
| xml:str | Optional XML payload containing the uploaded file. |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Optional request context. |
| RESPONSE:ZPublisher.HTTPResponse.HTTPResponse | Optional response context. |
| Returns | |
| str | Stored filename. |
Quote a value according to the declared type of a table column.
| Parameters | |
| tablename:str | Entity name. |
| columnname:str | Column identifier. |
| v:object | Raw value to quote. |
| Returns | |
| str | SQL literal suitable for inline substitution. |
Substitute positional parameter markers with quoted SQL literals.
| Parameters | |
| sql:str | SQL statement containing ? placeholders. |
| params:tuple | Values for the placeholders. |
| Returns | |
| str | SQL statement with substituted literals. |
Delete the file referenced by a blob column and return its replacement value.
| Parameters | |
| tablename:str | Entity name. |
| id:str | Blob column id. |
| rowid:object | Primary-key value of the affected row. |
| Returns | |
| object | Replacement column value after deletion. |
Load a blob from the filesystem and return it as a ZMS file object.
| Parameters | |
| tablename:str | Entity name. |
| id:str | Blob column id. |
| rowid:object | Primary-key value of the affected row. |
| cache:str | Cache-Control header value for responses. |
| REQUEST:ZPublisher.HTTPRequest.HTTPRequest | Optional request context. |
| RESPONSE:ZPublisher.HTTPResponse.HTTPResponse | Optional response used to set headers. |
| Returns | |
| object | Image or file wrapper, or None when no blob exists. |
Store blob data on the server filesystem and return the stored filename.
| Parameters | |
| tablename:str | Entity name. |
| id:str | Blob column id. |
| rowid:object | Optional primary-key value of the affected row. |
| file:object | Uploaded file object. |
| xml:str | Optional XML payload used to reconstruct the uploaded file. |
| Returns | |
| str | Stored filename. |