Skip to content

Commit

Permalink
01.08.04 - is_inserted etc (issue 11)
Browse files Browse the repository at this point in the history
  • Loading branch information
valhuber committed Apr 16, 2023
1 parent 58c8708 commit 1387e00
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/LogicBank.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
14 changes: 14 additions & 0 deletions logic_bank/exec_row_logic/logic_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LogicRow:
Passed to user logic, mainly to make updates - with logic, for example
row = sqlalchemy read
logic_row.update(row=row, msg="my log message")
Additional instance variables: ins_upd_dlt, nest_level, session, etc.
Expand All @@ -52,6 +53,7 @@ def __init__(self, row: base, old_row: base, ins_upd_dlt: str, nest_level: int,
self.old_row = old_row
""" old mapped row """
self.ins_upd_dlt = ins_upd_dlt
""" values are 'ins', 'upd' or 'dlt' """
self.ins_upd_dlt_initial = ins_upd_dlt # order inserted, then adjusted
self.nest_level = nest_level
self.reason = "?" # set by insert, update and delete
Expand Down Expand Up @@ -261,6 +263,18 @@ def _copy_rules(self):
each_copy_rule.execute(logic_row, parent_logic_row)
self.log(f'copy_rules for role: {role_name} - {attributes_copied}')

def is_inserted(self) -> bool:
""" return True if self.ins_upd_dlt == "ins" else False """
return True if self.ins_upd_dlt == "ins" else False

def is_updated(self) -> bool:
""" return True if self.ins_upd_dlt == "upd" else False """
return True if self.ins_upd_dlt == "upd" else False

def is_deleted(self) -> bool:
""" return True if self.ins_upd_dlt == "dlt" else False """
return True if self.ins_upd_dlt == "dlt" else False

def _get_parent_role_def(self, parent_role_name: str):
""" returns sqlalchemy role_def """
my_mapper = object_mapper(self.row)
Expand Down
3 changes: 3 additions & 0 deletions logic_bank/logic_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class LogicBank:
session.commit() # LogicBank listeners execute rules relevant for submitted changes
.. _Rule Summary:
https://apilogicserver.github.io/Docs/Logic/
https://github.com/valhuber/LogicBank/wiki/Rule-Summary
"""
Expand Down
2 changes: 1 addition & 1 deletion logic_bank/rule_bank/rule_bank_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sqlalchemy.orm import session
import logging

__version__ = "01.08.03"
__version__ = "01.08.04"


def setup(a_session: session):
Expand Down

0 comments on commit 1387e00

Please sign in to comment.