Wrapper Layer
Direct access to the Commence Com object is provided by the wrapper layer.
DB Wrapper
- class CmcConnector(commence_instance_name='Commence.DB')[source]
Singleton managing cached connections to multiple Commence databases.
- class CommenceWrapper(commence_instance_name='Commence.DB')[source]
Commence Database object.
Entry point for
cmc_csr.CsrCmc
andconversation.CommenceConversation
.~~Caching Inherited from
CmcConnector
.~~ caching breaks in multithreaded environments- commence_instance_name
The name of the Commence instance.
- Type:
str
- commence_dispatch
The Commence COM object.
- Type:
Dispatch
- get_new_cursor_wrapper(name=None, mode=CursorType.CATEGORY, pilot=False, internet=False)[source]
Create a cursor wrapper.
CursorTypes CATEGORY and VIEW require name to be set.
- Parameters:
name (str|None) – Name of the category or view to open.
mode (enums_cmc.CursorType) – Cursor type
pilot (bool) – Pilot flag - use palmpilot preferences
internet (bool) – Internet flag - use internet preferences
- Returns:
A Csr object on success.
- Return type:
CsrCmc
- Raises:
ValueError if no name given for name based searches –
- get_conversation_api(topic, application_name='Commence')[source]
Create a conversation object.
- Parameters:
topic (str) – DDE Topic name, must be a valid Commence topic name.
application_name (str) – DDE Application name. The only valid value is “Commence”.
- Returns:
A CommenceConversation object on success.
- Return type:
CommenceConversation
- Raises:
ValueError if failure. –
- property name: str
(read-only) Name of the Commence database.
- property path: str
(read-only) Full path of the Commence database.
- property registered_user: str
(read-only) CR/LF delimited string with username, company name, and serial number.
(read-only) TRUE if the database is enrolled in a workgroup.
- property version: str
(read-only) Version number in x.y format.
- property version_ext: str
(read-only) Version number in x.y.z.w format.
Cursor Wrapper
- class CursorWrapper(cmc_cursor)[source]
Thin wrapper on the Commence Cursor object using pywin32.
- property category
- property column_count
- property row_count
- set_filter(filter_text)[source]
Defines a filter clause for the cursor.
- Parameters:
filter_text (str) – Text defining the new filter clause. Syntax is identical to the one used by the DDE ViewFilter request.
- Returns:
True on success.
- Return type:
bool
If the cursor is opened in CURSOR_VIEW mode, the set_filter only affects the cursor’s secondary filter. That is, when building the rowset, the view’s filter is first evaluated. Items that match are then passed through the cursor’s secondary filter. The rowset only contains items that satisfy both filters.
- set_filter_logic(logic_text)[source]
Defines the filter logic for the cursor.
- Parameters:
logic_text (str) – Text defining the new filter logic. Syntax is identical to the one used by the DDE ViewConjunction request.
Unless otherwise specified, the default logic is AND, AND, AND.
- set_sort(sort_text)[source]
Defines the sort criteria for the cursor.
- Parameters:
sort_text (str) – Text defining the new sort criteria. Syntax is identical to the one used by the DDE ViewSort request.
If the cursor is opened in CMC_CURSOR_VIEW mode, the sort defaults to the view’s sort. All other cursor modes default to ascending sort by the Name field.
- set_column(column_index, field_name, flags=OptionFlagInt.NONE)[source]
Defines the column set for the cursor.
- Parameters:
column_index (int) – The (0-based) index of the column to set.
field_name (str) – Name of the field to use in this column.
flags (int) – Option flags (Logical OR of option flags like CMC_FLAG_ALL to create column set of all fields).
- Returns:
True on success, False on error.
- Return type:
bool
When defining a column set, the columns must be defined in sequential order (0, 1, 2, etc.). This is to prevent problems with undefined columns (e.g. 0, 1, 3, …). Duplicate columns are not supported. Each column must map to a different field. Not all Commence field types can be included in the cursor definition. The set of supported field types exactly matches those fields that can be displayed in a Commence report (minus combined fields and indirect fields).
- seek_row(start, rows)[source]
Seek to a particular row in the cursor.
- Parameters:
start (int) – Position to move from. Can be one of the following: - 0 (BOOKMARK_BEGINNING) - from first row - 1 (BOOKMARK_CURRENT) - from current row - 2 (BOOKMARK_END) - from last row
rows (int) – Number of rows to move the current row pointer.
- Returns:
Number of rows moved.
- Return type:
int
- Raises:
CmcError on fail –
For any cursor, there is a ‘current row pointer’. When the cursor is created, this defaults to the first row. SeekRow will reposition the current row pointer. GetQueryRowSet, GetEditRowSet, and GetDeleteRowSet will also advance the current row pointer.
- seek_row_fractional(numerator, denominator)[source]
Seek to a fractional position in the cursor.
- Parameters:
numerator (int) – Numerator for fractional position in the cursor.
denominator (int) – Denominator for the fractional position in the cursor.
- Returns:
Actual number of rows moved, -1 on error.
- Return type:
int
- get_query_row_set(limit=None)[source]
Create a rowset object with the results of a query.
- Parameters:
limit (int) – Maximum number of rows to retrieve.
- Returns:
Pointer to rowset object on success, None on error.
- Return type:
The rowset inherits the column set from the cursor. The cursor’s ‘current row pointer’ determines the first row to be included in the rowset. The returned rowset can have fewer than limit rows (e.g. if the current row pointer is near the end). Use CommenceXRowSet.row_count to determine the actual row count. GetQueryRowSet will advance the ‘current row pointer’ by the number of rows in the rowset.
- get_query_row_set_by_id(row_id)[source]
- Parameters:
row_id (
str
) – str Unique ID string obtained from GetRowID().- Returns:
Pointer to rowset object on success, NULL on error.
- Raises:
PyCommenceNotFoundError – Row not found.
PyCommenceServerError – Error getting row.
PyCommenceMaxExceededError – Multiple rows found.
The rowset inherits column set from the cursor. The cursor’s ‘current row pointer’ is not advanced.
- get_add_row_set(limit=1, shared=True)[source]
Creates a rowset of new items to add to the database.
- Parameters:
limit (int) – The number of rows to create.
shared (bool) – True if the row/s are to be shared.
- Returns:
A rowset object for adding new items.
- Return type:
The rowset inherits the column set from the cursor. When first created, each row is initialized to field default values.
- get_edit_row_set(limit=None)[source]
Creates a rowset of existing items for editing.
- Parameters:
limit (int) – The number of rows to retrieve, defaults to all rows in csr.
- Returns:
A rowset object for editing existing items, or None on error.
- Return type:
The rowset inherits the column set from the cursor.
- get_edit_row_set_by_id(row_id)[source]
Creates a rowset for editing a particular row.
- Parameters:
row_id (str) – Unique ID string obtained from GetRowID().
- Returns:
A rowset object for editing a particular row, or None on error.
- Return type:
The rowset inherits the column set from the cursor. The cursor’s ‘current row pointer’ is not advanced.
- get_delete_row_set(limit=1)[source]
Creates a rowset of existing items for deletion.
- Parameters:
limit (int) – The number of rows to retrieve.
- Returns:
A rowset object for deleting existing items, or None on error.
- Return type:
The rowset inherits the column set from the cursor.
- get_delete_row_set_by_id(row_id, flags=OptionFlagInt.NONE)[source]
Creates a rowset for deleting a particular row.
- Parameters:
row_id (str) – Unique ID string obtained from GetRowID().
flags (int, optional) – Unused at present, must be 0. Defaults to 0.
- Returns:
A rowset object for deleting a particular row
- Return type:
The rowset inherits the column set from the cursor. The cursor’s ‘current row pointer’ is not advanced.
- set_active_item(category, row_id)[source]
Set active item used for view cursors using a view linking filter_str.
- Parameters:
category (str) – Category name of the active item used with view linking filter_str.
row_id (str) – Unique ID string obtained from GetRowID()
- Returns:
True on success, else False on error.
- Return type:
bool
- set_active_date(active_date)[source]
Set active active_date used for view cursors using a view linking filter_str.
- Parameters:
active_date (str) – Date value used with view linking filter_str supports active_date values such as ‘today’.
- Returns:
True on success, else False on error.
- Return type:
bool
- set_active_date_range(start, end)[source]
Set active active_date range used for view cursors using a view linking filter_str.
- Parameters:
start (str) – Date value of start active_date used with view linking filter_str Supports natural language values such as ‘today’.
end (str) – Date value of end active_date used with view linking filter_str. Supports natural language values such as ‘next monday’.
- Returns:
True on success, else False on error.
- Return type:
bool
Adds a related (indirect/connected field) column to the cursor.
- Parameters:
col (int) – The (0-based) index of the column to set.
con_name (str) – Name of the connection to use in this column.
connected_cat (str) – Name of the connected Category to use in this column.
col_name (str) – Name of the field in the connected Category to use in this column.
flags (int) – Option flags (Logical OR of option flags like CMC_FLAG_ALL to create column set of all fields).
- Returns:
True on success, False on error.
- Return type:
bool
Example
set_related_column(0, “Relates To”, “History”, “Date”, 0) This call will add the Date field to the cursor via the ‘Relates to History’ connection.
RowSet Wrappers
- class RowSetBase(cmc_rs)[source]
- property headers: list
Returns a list of all column labels.
- property column_count: int
Returns the number of columns in the row set.
- property row_count: int
Returns the number of rows in the row set.
- get_value(row_index, column_index, flags=16)[source]
Retrieves the value at the specified row and column.
- Parameters:
row_index (
int
) – Index of the row.column_index (
int
) – Index of the column.flags (
int
) – CMC_FLAG_CANONICAL - return field value in canonical form
- Return type:
str
- Returns:
Value at the specified row and column.
- get_column_label(index, by_field=True)[source]
Retrieves the label of the specified column.
- Parameters:
index (
int
) – Index of the column.by_field (
bool
) – Return field label (ignore view labels).
- Return type:
str
- Returns:
Label of the specified column.
- get_column_index(label, by_field=True)[source]
Searches and retrieves the index of the specified column label.
- Parameters:
label (
str
) – Label of the column.by_field (
bool
) – Search by field label (ignore view labels).
- Return type:
int
- Returns:
Index of the specified column label.
- get_row(row_index, delim=';', cannonical=True)[source]
Retrieves the values of the specified row.
- Parameters:
row_index (
int
) – Index of the row.delim (
str
) – Delimiter to use between values.cannonical (
bool
) – Return field value in canonical form.
- Return type:
str
- Returns:
Values of the specified row.
- get_row_id(row_index)[source]
Retrieves the ID of the specified row.
- Parameters:
row_index (
int
) – Index of the row.- Return type:
str
- Returns:
ID of the specified row.
- row_dicts_list(num=None)[source]
Returns a dictionary of the first num rows.
- Return type:
list
[dict
[str
,str
]]
- rows(count=None)[source]
Generates dicts of the first count rows.
- Return type:
Generator
[dict
[str
,str
],None
,None
]
Determines whether the row at the specified index is shared.
- Parameters:
row_index (
int
) – Index of the row.- Return type:
bool
- Returns:
True if the row is shared, False otherwise.
- class RowSetQuery(cmc_rs)[source]
- get_field_to_file(row_index, column_index, file_path, canonical=True)[source]
Saves the field value at the given (row, column) to a file.
- Parameters:
row_index (int) – The index of the row.
column_index (int) – The index of the column.
file_path (str) – The path where the field value will be saved to.
canonical (bool) – Return field value in canonical form.
- Returns:
True on success, False on failure.
- Return type:
bool
- class RowSetModifies(cmc_rs)[source]
adds functionality to modify rows
- modify_value(row_index, column_index, value)[source]
Modifies a field value in the rowset.
- Parameters:
row_index (int) – The index of the row to modify.
column_index (int) – The index of the column in the row to modify.
value (str) – The new value for the field.
- Returns:
True on success, False on failure.
- Return type:
bool
- modify_row(row_index, row_dict)[source]
Modifies a row in the rowset. :type row_index:
int
:param row_index: The index of the row to modify. :type row_index: int :type row_dict:dict
:param row_dict: A dictionary of column names and values to modify. :type row_dict: dict- Return type:
None
- class RowSetAdd(cmc_rs)[source]
Represents a set of new items to add to the database.
- Inherits from:
RowSetBase: Base class for Commence Row Set objects. RowSetModifies: Base class for Write-Enabled RowSet objects.
- class RowSetDelete(cmc_rs)[source]
Represents a set of items to delete from the database.
- Inherits from:
RowSetBase: Base class for Commence Row Set objects.
- get_row_id(row_index)[source]
Retrieves the ID of the specified row.
- Parameters:
row_index (
int
) – Index of the row.- Return type:
str
- Returns:
ID of the specified row.
- delete_row(row_index)[source]
Marks a row for deletion. Deletion is not permanent until Commit() is called.
- Parameters:
row_index (int) – The index of the row to mark for deletion.
- Returns:
True on success, False on failure.
- Return type:
bool
- commit_get_cursor()[source]
Makes row modifications permanent (commit to disk) and returns a cursor.
- Returns:
Cursor object with the committed data.
- Return type:
CommenceCursor
- modify_value(row_index, column_index, value)[source]
Modifies a field value in the rowset.
- Parameters:
row_index (int) – The index of the row to modify.
column_index (int) – The index of the column in the row to modify.
value (str) – The new value for the field.
- Returns:
True on success, False on failure.
- Return type:
bool
Commence Conversation Wrapper
- class ConversationAPI(cmc_conversation)[source]
Thin Wrapper on Commence’s Conversation object using DDE.
- execute(dde_command)[source]
Executes the DDE Command.
- Parameters:
dde_command (str) – The DDE command to execute.
- Returns:
True on successful execution, False otherwise.
- Return type:
bool
- request(dde_command)[source]
Processes the DDE Request.
- Parameters:
dde_command (str) – The DDE command to process.
- Returns:
The result of processing the DDE request.
- Return type:
str
ICommence Interface Wrapper
Commence RM Type Library - WIP
MakePy generated api for Commence Rm COM object, mostly as generated
- class IApp(oobj=None)[source]
IApp Interface
- CLSID = IID('{9419F0A3-A8ED-11D4-824C-0050DAC366C6}')
- coclass_clsid = IID('{9419F0A4-A8ED-11D4-824C-0050DAC366C6}')
- class ICmcApplication(oobj=None)[source]
- CLSID = IID('{18884001-732C-11D0-AC0A-00A02485EC15}')
- coclass_clsid = None
- class ICommenceAddRowSet(oobj=None)[source]
- CLSID = IID('{C5D7DAE3-9BEC-11D1-99CC-00C04FD3695E}')
- coclass_clsid = None
- ModifyRow(nRow=<PyOleEmpty object>, nCol=<PyOleEmpty object>, pBuf=<PyOleEmpty object>, flags=<PyOleEmpty object>)[source]
- class ICommenceConversation(oobj=None)[source]
- CLSID = IID('{9D1EB82D-6F4F-4DCF-BF8C-9E0D33FE83E1}')
- coclass_clsid = None
- class ICommenceCursor(oobj=None)[source]
- CLSID = IID('{C5D7DAE0-9BEC-11D1-99CC-00C04FD3695E}')
- coclass_clsid = None
- SetActiveDateRange(startDate=<PyOleEmpty object>, endDate=<PyOleEmpty object>, flags=<PyOleEmpty object>)[source]
- SetActiveItem(pCategoryName=<PyOleEmpty object>, pRowID=<PyOleEmpty object>, flags=<PyOleEmpty object>)[source]
- SetColumn(nColumn=<PyOleEmpty object>, pName=<PyOleEmpty object>, flags=<PyOleEmpty object>)[source]
- class ICommenceDB(oobj=None)[source]
- CLSID = IID('{92A04260-BE5C-11D1-99CC-00C04FD3695E}')
- coclass_clsid = IID('{92A04261-BE5C-11D1-99CC-00C04FD3695E}')
- GetConversation(pszApplicationName=<PyOleEmpty object>, pszTopic=<PyOleEmpty object>)[source]
- Return type:
- class ICommenceDeleteRowSet(oobj=None)[source]
- CLSID = IID('{C5D7DAE5-9BEC-11D1-99CC-00C04FD3695E}')
- coclass_clsid = None
- class ICommenceEditRowSet(oobj=None)[source]
- CLSID = IID('{C5D7DAE4-9BEC-11D1-99CC-00C04FD3695E}')
- coclass_clsid = None
- ModifyRow(nRow=<PyOleEmpty object>, nCol=<PyOleEmpty object>, pBuf=<PyOleEmpty object>, flags=<PyOleEmpty object>)[source]
- class ICommenceQueryRowSet(oobj=None)[source]
- CLSID = IID('{C5D7DAE2-9BEC-11D1-99CC-00C04FD3695E}')
- coclass_clsid = None
- GetFieldToFile(nRow=<PyOleEmpty object>, nCol=<PyOleEmpty object>, filename=<PyOleEmpty object>, flags=<PyOleEmpty object>)[source]
- class IConnOA(oobj=None)[source]
- CLSID = IID('{47A27291-7572-11D0-AC0B-00A02485EC15}')
- coclass_clsid = None
- SetActiveDateRange(startDate=<PyOleEmpty object>, endDate=<PyOleEmpty object>, flags=<PyOleEmpty object>)[source]
- class IControlOA(oobj=None)[source]
- CLSID = IID('{F180CB64-D4F0-464B-8EB6-0008689A24A6}')
- coclass_clsid = None
- class IDatabaseOA(oobj=None)[source]
- CLSID = IID('{845A7A11-88F6-11D0-AC0E-00A02485EC15}')
- coclass_clsid = None
- class IFieldOA(oobj=None)[source]
- CLSID = IID('{383CFA14-73D5-11D0-AC0B-00A02485EC15}')
- coclass_clsid = None
- class IFormOA(oobj=None)[source]
- CLSID = IID('{654E7740-2AB6-11D0-8A93-444553540000}')
- coclass_clsid = IID('{654E7741-2AB6-11D0-8A93-444553540000}')
- class IFullControl(oobj=None)[source]
IFullControl Interface
- CLSID = IID('{BE0B47E8-0BD2-4114-923E-EEFFEB740942}')
- coclass_clsid = IID('{789D254B-2D9B-487C-BABF-89D0EF6BD76C}')
- class ISimple(oobj=None)[source]
ISimple Interface
- CLSID = IID('{1C9DF726-86D4-4C5B-8398-7418F0903597}')
- coclass_clsid = IID('{DADC9CCF-FA28-4738-B142-B4CBD17267A6}')
- class IUIObj(oobj=None)[source]
IUIObj Interface
- CLSID = IID('{2BAE3CB5-A80C-11D4-A632-0040D0051497}')
- coclass_clsid = IID('{2BAE3CB6-A80C-11D4-A632-0040D0051497}')
- class Isample(oobj=None)[source]
Isample Interface
- CLSID = IID('{6F0D28AA-9A6E-44B2-AAF5-A98FFD14B2C1}')
- coclass_clsid = IID('{F22497D6-AAC1-4DA4-9DC7-CD5C1536431C}')
- class App(oobj=None)[source]
- CLSID = IID('{9419F0A4-A8ED-11D4-824C-0050DAC366C6}')
- coclass_sources = []
- coclass_interfaces = [<class 'pycommence.wrapper._icommence.IApp'>]
- class CommenceDB(oobj=None)[source]
- CLSID = IID('{92A04261-BE5C-11D1-99CC-00C04FD3695E}')
- coclass_sources = []
- coclass_interfaces = [<class 'pycommence.wrapper._icommence.ICommenceDB'>]
- default_interface[source]
alias of
ICommenceDB
- class FormOA(oobj=None)[source]
- CLSID = IID('{654E7741-2AB6-11D0-8A93-444553540000}')
- coclass_sources = [<class 'pycommence.wrapper._icommence._DFormOAEvents'>]
- coclass_interfaces = [<class 'pycommence.wrapper._icommence.IFormOA'>]
- class FullControl(oobj=None)[source]
- CLSID = IID('{789D254B-2D9B-487C-BABF-89D0EF6BD76C}')
- coclass_sources = [<class 'pycommence.wrapper._icommence._IFullControlEvents'>]
- coclass_interfaces = [<class 'pycommence.wrapper._icommence.IFullControl'>]
- default_interface[source]
alias of
IFullControl
- class Simple(oobj=None)[source]
- CLSID = IID('{DADC9CCF-FA28-4738-B142-B4CBD17267A6}')
- coclass_sources = []
- coclass_interfaces = [<class 'pycommence.wrapper._icommence.ISimple'>]