NOTICE: All information contained herein is, and remains
the property of TechnoCore Automate.
ObjChannel is a Python class designed for managing and rendering email channels. It handles various aspects of email generation, including dynamic content processing, attachment handling, and integration with reporting and user management systems.
__init__(self, DB: Objects.DatabaseConnection = 0)Initializes the ObjChannel object.
DB: An optional database connection object.process_text(self, text: str) -> strProcesses a given text string, replacing placeholders with values from the object's attributes and other processed text.
text: The input text string containing placeholders.Example:
channel_obj = ObjChannel(db_connection)
channel_obj._Docname = "MyDocument"
processed_text = channel_obj.process_text("This is a test for $docname$.")
print(processed_text)
Read(self, channel: str, context: list = []) -> NoneReads channel configuration from the database based on the provided channel name and context.
channel: The name of the channel to read.context: A list of context information to be loaded into the channel object.Example:
channel_obj = ObjChannel(db_connection)
channel_obj.Read("newsletter_channel")
Create(self, channel: str) -> strCreates a new channel entry in the database.
channel: The name of the channel to create.Example:
channel_obj = ObjChannel(db_connection)
sql_query = channel_obj.Create("new_channel")
Update(self) -> strUpdates the current channel entry in the database.
Example:
channel_obj = ObjChannel(db_connection)
channel_obj.Read("newsletter_channel")
channel_obj._Description = "Updated newsletter channel"
sql_query = channel_obj.Update()
get_email_banner(self, name: str = "", guid: str = "") -> tuple[str, str]Retrieves the folder and filename for an email banner image.
name: The name of the banner (e.g., "header", "footer").guid: An optional GUID for the banner.Example:
channel_obj = ObjChannel(db_connection)
folder, filename = channel_obj.get_email_banner("header")
print(f"Folder: {folder}, Filename: {filename}")
size_image(self, image_folder: str, image_name: str) -> tuple[int, int]Gets the dimensions (width and height) of an image.
image_folder: The folder path where the image is located.image_name: The name of the image file.Example:
channel_obj = ObjChannel(db_connection)
width, height = channel_obj.size_image("resource.images/package.core/", "my_banner.jpg")
print(f"Width: {width}, Height: {height}")
render_email_banner(self, guid: str = "", name: str = "", banner_type: str = "head") -> tupleRenders an HTML email banner.
guid: Unique identifier for the specific email banner.name: Optional name parameter for the banner.banner_type: Type of banner to be rendered, defaults to "head".Example:
channel_obj = ObjChannel(db_connection)
html_banner, images = channel_obj.render_email_banner("some-guid", banner_type="header")
print(html_banner)
render_report(self, reportname: str, folder: str = "", guid: str = "") -> strRenders a report based on the specified report name, folder path, and GUID.
reportname: The name of the report to render.folder: The folder where the report should be published.guid: A unique identifier for the report.Example:
channel_obj = ObjChannel(db_connection)
report_html = channel_obj.render_report("sales_report", "/tmp/reports", "report-guid")
print(report_html)
next_weekday(self, weekday: int = 0) -> strCalculates and returns the date of the next specified weekday.
weekday: The target weekday (0 for Monday, 6 for Sunday).Example:
channel_obj = ObjChannel(db_connection)
next_monday = channel_obj.next_weekday(0) # Next Monday
print(next_monday)
patch_param(self, guid: str, notes: str) -> strUpdates the given text based on the provided guid and notes while performing a series of SQL operations and internal transformations.
guid: The unique identifier used in SQL queries and placeholder replacements.notes: The text content that will have placeholder replacements applied.Example:
channel_obj = ObjChannel(db_connection)
patched_notes = channel_obj.patch_param("user-guid", "Hello $firstname$, your GUID is $guid$.")
print(patched_notes)
render_attachment_document(self, guid: str, documents: str) -> NoneProcesses a list of document names, retrieves their definitions from the database, creates corresponding local directories if they don't exist, processes the documents, and appends them to an attachments list.
guid: A unique identifier for the attachment process.documents: A comma-separated string of document names to be processed.Example:
channel_obj = ObjChannel(db_connection)
channel_obj.render_attachment_document("attachment-guid", "document1,document2")
render_attachment_report_pdfs(self, guid: str = "", reports: str = "") -> NoneRenders reports as PDFs and adds them as attachments.
guid: A unique identifier for the attachment process.reports: A comma-separated string of report names to be rendered as PDFs.Example:
channel_obj = ObjChannel(db_connection)
channel_obj.render_attachment_report_pdfs("report-pdf-guid", "report_a,report_b")
render_attachment_mail_pdf(self, Guid: str = "") -> NoneGenerates a PDF from the email content and attaches it.
Guid: The GUID of the email.Example:
channel_obj = ObjChannel(db_connection)
channel_obj.final_message = "<h1>Email Content</h1>"
channel_obj.final_description = "Email Subject"
channel_obj.Guid = "email-guid"
channel_obj.render_attachment_mail_pdf("email-guid")
render_pdf(self, guid: str = "") -> strRenders various types of PDFs (from email content, reports, or documents) and adds them as attachments.
guid: The GUID for the PDF rendering process.Example:
channel_obj = ObjChannel(db_connection)
pdf_filename = channel_obj.render_pdf("pdf-guid")
print(pdf_filename)
render_attachment_reports(self, guid: str, reports: str) -> NoneRenders reports and adds them as attachments.
guid: The GUID for the attachment process.reports: A comma-separated string of report names to be rendered.Example:
channel_obj = ObjChannel(db_connection)
channel_obj.render_attachment_reports("report-attach-guid", "report_x,report_y")
render_email(self, guid: str, email: str = "", Filter: str = "") -> strRenders the complete email content, including banners, notes, reports, and subscription links.
guid: The GUID of the email.email: The recipient's email address.Filter: An optional filter string.Example:
channel_obj = ObjChannel(db_connection)
html_email = channel_obj.render_email("email-guid", "recipient@example.com")
print(html_email)
render_attachments(self) -> listRenders and collects all attachments for the email.
Example:
channel_obj = ObjChannel(db_connection)
attachments = channel_obj.render_attachments()
print(attachments)
Mail(self, to_addr: str = "", title: str = "", message: str = "", Filter: str = "") -> strSends an email using the configured channel settings.
to_addr: The recipient's email address.title: The subject of the email.message: The message body.Filter: An optional filter string.Example:
channel_obj = ObjChannel(db_connection)
status = channel_obj.Mail(
to_addr="recipient@example.com",
title="Important Update",
message="Please read this important message."
)
print(status)
The ObjChannel module has comprehensive test coverage for communication channel functionality.
| Test Suite | Tests | Type | Purpose |
|---|---|---|---|
test_ObjChannel.py |
96 | Unit | Channel configuration, email sending, template rendering, multi-channel support |
| Total | 96 (93 passed, 3 skipped) |
# Run all ObjChannel tests
pytest resource.test/pytests/factory.core/test_ObjChannel.py -v
Uses pyminizip (Linux) or pyzipper (Windows) for AES-256
encrypted email attachments. Falls back gracefully:
pyminizip (C extension, Linux) → pyzipper (pure Python, cross-platform) → log warning
zipfile does NOT support AES-256pyzipper is a drop-in replacement, same AES-256 standard