| |
- Data
- DocType
- Table
class Data |
|
Selected documents and tables from a CDR instance
Attributes:
tables - dictionary of Table objects, indexed by table name
docs - dictionary of DocType objects, indexed by type name |
|
Methods defined here:
- __init__(self, source, old=None)
- Collects table and document information for a CDR tier.
Pass:
source - either a directory name or a database cursor object
old - optional Data object for the data from the DEV tier
which was preserved before a refresh of the database
from the production server
When a cursor is passed for 'source' the documents and tables
are read directly from the database for the local tier. If
a string is passed as the 'source' argument it is assumed to
be the path (relative or absolute) for the location of the
data captured by the PullDevData.py script (q.v.).
The directory structure for the preserved data uses subdirectories
for each of the document types for which documents have been
preserved, as well as a subdirectory named 'tables' (since
the CDR naming convention for document types always uses the
best practice of using a singular noun, there should never
be a conflict with the name 'tables'). Within each document
type subdirectory is a file for each document of that type,
with a name in the form nnnnnn.cdr, where nnnnnn is the integer
form of the CDR document's ID. Each such file contains a
serialized (using Python's builtin repr() function) sequence
of CDR document ID, document title, and document XML. The
'tables' subdirectory contains one file for each preserved
table. The file name is the table's name. The first line in each
file is a sequence containing the names of the columns in the
table, in the order of the table's definition. The subsequent
lines each represent one row in the database table, as a
sequence of values in the same column order as used in the
first line.
For example:
DevData-20140227075603
Filter
100.cdr
101.cdr
103.cdr
:
:
PublishingSystem
176.cdr
178.cdr
257983.cdr
Schema
179.cdr
:
:
tables
action
active_status
:
:
- filter_set_member(self, row)
- Returns a tuple with denormalized filter_set_member row values
- grp_action(self, row)
- Returns a string with denormalized grp_action row values
- grp_usr(self, row)
- Returns a string with denormalized grp_usr row values
- link_properties(self, row)
- Returns a tuple with denormalized link_properties row values
- link_target(self, row)
- Returns a tuple with denormalized link_target row values
- link_xml(self, row)
- Returns a tuple with denormalized link_xml row values
|
class DocType |
|
Contains documents for a single document type from one of the CDR tiers.
Attributes:
name - document type name (e.g., "Filter")
docs - dictionary with keys containing normalized document
titles (leading and trailing spaces stripped, and
case folded), and values containing tuples of CDR
document ID, unique document title, and document
serialized XML; strings are Unicode
map - dictionary mapping CDR document IDs to document titles
Note that preservation of documents from the DEV tier relies on
unique document titles within each document type. This is guaranteed
to be true for the base control document types (Schema, Filter, and
PublishingControl). It is the responsibility of the developer to
ensure that this is true for documents of any any additional document
types which must be preserved. |
|
Methods defined here:
- __init__(self, name, source)
- Loads the documents from the file system or the database.
Pass:
name - document type name (e.g., "Filter")
source - either a string naming file system directory or a
database cursor
|
class Table |
|
Holds data for a CDR table.
Attributes:
name - table name
cols - column names (in order as stored in the database)
values - sequence of row tuples with column values in db order
rows - sequence of dictionaries mapping column names to values
names - rows indexed by 'name' column (for tables with such a column)
map - rows indexed by 'id' column (for tables with an id column) |
|
Methods defined here:
- __init__(self, name, source)
- Populates a Table object with data from a CDR database table.
Pass:
name - database table name
source - either a string naming a directory or a db cursor
| |